[diffoscope] 12/12: Store hide-options as an accumulated list.

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Wed Mar 8 15:59:10 CET 2017


This is an automated email from the git hooks/post-receive script.

siamezzze-guest pushed a commit to branch siamezzze/hide-profiles-experiment
in repository diffoscope.

commit 26423dc878e8d1cc6941a5cd1fc33a29612f63ca
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Sun Mar 5 12:16:26 2017 +0200

    Store hide-options as an accumulated list.
---
 diffoscope/comparators/debian.py |  2 +-
 diffoscope/comparators/elf.py    |  4 ++--
 diffoscope/comparators/gzip.py   |  2 +-
 diffoscope/config.py             | 24 ++++++++++++------------
 diffoscope/main.py               | 11 ++++++-----
 5 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/diffoscope/comparators/debian.py b/diffoscope/comparators/debian.py
index 4a33c33..dce2512 100644
--- a/diffoscope/comparators/debian.py
+++ b/diffoscope/comparators/debian.py
@@ -126,7 +126,7 @@ class DebControlFile(File):
         for field in sorted(set(self.deb822.keys()).union(set(other.deb822.keys()))):
             if field.startswith('Checksums-') or field == 'Files':
                 continue
-            if Config().hide_section == "buildinfo-" + field.lower():
+            if "buildinfo-" + field.lower() in Config().hide_section:
                 logger.debug("Section %s of %s and %s skipped due to "
                              "hide-section option" %
                              (field, self.path, other.path))
diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index 04c4615..d9ce216 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -412,7 +412,7 @@ class ElfContainer(Container):
 
                 if name.startswith('.debug') or name.startswith('.zdebug'):
                     has_debug_symbols = True
-                    if Config().hide_section == "debug-symbols":
+                    if "debug-symbols" in Config().hide_section:
                         logger.debug("Skipping %s due to request to hide "
                                      "debug symbols" % name)
                         continue
@@ -437,7 +437,7 @@ class ElfContainer(Container):
             )
             raise OutputParsingError(command, self)
 
-        if not has_debug_symbols and Config().hide_section != 'debug-symbols':
+        if not has_debug_symbols and 'debug-symbols' not in Config().hide_section:
             self._install_debug_symbols()
 
     @tool_required('objcopy')
diff --git a/diffoscope/comparators/gzip.py b/diffoscope/comparators/gzip.py
index 2d4f4f8..e4896ae 100644
--- a/diffoscope/comparators/gzip.py
+++ b/diffoscope/comparators/gzip.py
@@ -64,7 +64,7 @@ class GzipFile(File):
     RE_FILE_TYPE = re.compile(r'^gzip compressed data\b')
 
     def compare_details(self, other, source=None):
-        if Config().hide_timestamp and Config().hide_timestamp == "gzip-metadata":
+        if "gzip-metadata" in Config().hide_timestamp:
             logger.debug("Skipping gzip-metadata")
             return []
         return [Difference.from_text(self.magic_file_type, other.magic_file_type, self, other, source='metadata')]
diff --git a/diffoscope/config.py b/diffoscope/config.py
index 79a4c73..ac37c45 100644
--- a/diffoscope/config.py
+++ b/diffoscope/config.py
@@ -34,18 +34,18 @@ class Config(object):
     fuzzy_threshold = 60
     enforce_constraints = True
     excludes = ()
-    hide_timestamp = None
-    buildinfo_sections = ['buildinfo-format', 'buildinfo-source',
-                          'buildinfo-binary', 'buildinfo-architecture',
-                          'buildinfo-version', 'buildinfo-binary-only-changes',
-                          'buildinfo-build-origin',
-                          'buildinfo-build-architecture',
-                          'buildinfo-build-date', 'buildinfo-build-path',
-                          'buildinfo-installed-build-depends',
-                          'buildinfo-environment'
-                          ]
-    other_sections = ["debug-symbols"]
-    hide_section = None
+    timestamps_choices = ['gzip-metadata']
+    hide_timestamp = []
+    sections_choices = ['buildinfo-format', 'buildinfo-source',
+                        'buildinfo-binary', 'buildinfo-architecture',
+                        'buildinfo-version', 'buildinfo-binary-only-changes',
+                        'buildinfo-build-origin',
+                        'buildinfo-build-architecture',
+                        'buildinfo-build-date', 'buildinfo-build-path',
+                        'buildinfo-installed-build-depends',
+                        'buildinfo-environment',
+                        "debug-symbols", ]
+    hide_section = []
 
     _singleton = {}
 
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 80e0dc8..cc5bf3b 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -162,12 +162,13 @@ def create_parser():
                         metavar='PATTERN', action='append', default=[],
                         help='Exclude files that match %(metavar)s')
     group3.add_argument('--hide-timestamp', dest='hide_timestamp',
-                        action='store', choices=['gzip-metadata'],
-                        help='hide certain timestamp differences')
+                        action='append', choices=['gzip-metadata'],
+                        help='hide certain timestamp differences',
+                        default=[])
     group3.add_argument('--hide-section', dest='hide_section',
-                        action='store', choices=Config().buildinfo_sections +
-                        Config().other_sections,
-                        help='hide certain timestamp differences')
+                        action='append', choices=Config().sections_choices,
+                        help='hide certain timestamp differences',
+                        default=[])
     group3.add_argument('--fuzzy-threshold', dest='fuzzy_threshold', type=int,
                         help='Threshold for fuzzy-matching '
                         '(0 to disable, %(default)s is default, 400 is high fuzziness)',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list