[Git][reproducible-builds/diffoscope][master] Don't pretty-print the JSON output by default as it will usually be so...

Chris Lamb gitlab at salsa.debian.org
Tue May 12 06:45:01 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
443e2baf by Chris Lamb at 2020-05-12T07:44:53+01:00
Don't pretty-print the JSON output by default as it will usually be so complicated to be unreadable by the human eye and it can be easily replaced by piping to "| jq".

- - - - -


2 changed files:

- diffoscope/presenters/json.py
- tests/data/output.json


Changes:

=====================================
diffoscope/presenters/json.py
=====================================
@@ -2,7 +2,7 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2017, 2019 Chris Lamb <lamby at debian.org>
+# Copyright © 2017, 2019-2020 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ class JSONPresenter(Presenter):
 
         root[0][JSON_FORMAT_MAGIC] = JSON_FORMAT_VERSION
         root[0].move_to_end(JSON_FORMAT_MAGIC, last=False)
-        self.print_func(json.dumps(root[0], indent=2))
+        self.print_func(json.dumps(root[0]))
 
     def visit_difference(self, difference):
         while self.depth + 1 < len(self.stack):


=====================================
tests/data/output.json
=====================================
@@ -1,26 +1 @@
-{
-  "diffoscope-json-version": 1,
-  "source1": "test1.tar",
-  "source2": "test2.tar",
-  "unified_diff": null,
-  "details": [
-    {
-      "source1": "file list",
-      "source2": "file list",
-      "unified_diff": "@@ -1,4 +1,4 @@\n-drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/\n--rw-r--r--   0 lunar     (1000) lunar     (1000)      446 2015-06-29 15:49:09.000000 dir/text\n-crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:09.000000 dir/null\n-lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/link -> broken\n+drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/\n+-rw-r--r--   0 lunar     (1000) lunar     (1000)      671 2015-06-29 15:49:41.000000 dir/text\n+crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:41.000000 dir/null\n+lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/link -> really-broken\n"
-    },
-    {
-      "source1": "dir/text",
-      "source2": "dir/text",
-      "unified_diff": "@@ -1,6 +1,12 @@\n+A common form of lorem ipsum reads:\n+\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor\n incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis\n nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu\n fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n+\n+\"Lorem ipsum\" text is derived from sections 1.10.32--3 of Cicero's De finibus\n+bonorum et malorum (On the Ends of Goods and Evils, or alternatively [About]\n+The Purposes of Good and Evil).\n"
-    },
-    {
-      "source1": "dir/link",
-      "source2": "dir/link",
-      "comments": [
-        "symlink"
-      ],
-      "unified_diff": "@@ -1 +1 @@\n-destination: broken\n+destination: really-broken\n"
-    }
-  ]
-}
+{"diffoscope-json-version": 1, "source1": "test1.tar", "source2": "test2.tar", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -1,4 +1,4 @@\n-drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/\n--rw-r--r--   0 lunar     (1000) lunar     (1000)      446 2015-06-29 15:49:09.000000 dir/text\n-crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:09.000000 dir/null\n-lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/link -> broken\n+drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/\n+-rw-r--r--   0 lunar     (1000) lunar     (1000)      671 2015-06-29 15:49:41.000000 dir/text\n+crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:41.000000 dir/null\n+lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/link -> really-broken\n"}, {"source1": "dir/text", "source2": "dir/text", "unified_diff": "@@ -1,6 +1,12 @@\n+A common form of lorem ipsum reads:\n+\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor\n incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis\n nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu\n fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n+\n+\"Lorem ipsum\" text is derived from sections 1.10.32--3 of Cicero's De finibus\n+bonorum et malorum (On the Ends of Goods and Evils, or alternatively [About]\n+The Purposes of Good and Evil).\n"}, {"source1": "dir/link", "source2": "dir/link", "comments": ["symlink"], "unified_diff": "@@ -1 +1 @@\n-destination: broken\n+destination: really-broken\n"}]}



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/443e2baf96e6f71f355bf3658d1b0aa77e4d1dae

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/443e2baf96e6f71f355bf3658d1b0aa77e4d1dae
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200512/388a7137/attachment.htm>


More information about the rb-commits mailing list