[diffoscope] 01/01: Add new feature to hide metadata generated by gzip more details : https://wiki.debian.org/ReproducibleBuilds/HideProfilesSpecification
Satyam Zode
satyamz-guest at moszumanska.debian.org
Thu Jun 2 11:49:23 CEST 2016
This is an automated email from the git hooks/post-receive script.
satyamz-guest pushed a commit to branch new-features
in repository diffoscope.
commit 4b40a4b2ea24ef94961caaaf750368ebbd9c75b1
Author: Satyam Zode <satyamzode at gmail.com>
Date: Thu Jun 2 15:16:08 2016 +0530
Add new feature to hide metadata generated by gzip
more details : https://wiki.debian.org/ReproducibleBuilds/HideProfilesSpecification
---
diffoscope/__main__.py | 3 +++
diffoscope/config.py | 9 +++++++++
diffoscope/presenters/html.py | 4 ++++
diffoscope/presenters/text.py | 11 +++++++++--
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/diffoscope/__main__.py b/diffoscope/__main__.py
index ac7913c..6d8f60c 100644
--- a/diffoscope/__main__.py
+++ b/diffoscope/__main__.py
@@ -87,6 +87,8 @@ def create_parser():
help='link to the jquery url, with --html-dir. Specify “disable” to disable JavaScript. When omitted diffoscope will try to create a symlink to a system installation. Known locations: %s' % ', '.join(JQUERY_SYSTEM_LOCATIONS))
parser.add_argument('file1', help='first file to compare')
parser.add_argument('file2', help='second file to compare')
+ parser.add_argument('--hide', dest='hide_profile', action='store',
+ choices={'metadata'}, help='hide certain differences')
if not tlsh:
parser.epilog = 'File renaming detection based on fuzzy-matching is currently disabled. It can be enabled by installing the “tlsh” module available at https://github.com/trendmicro/tlsh'
return parser
@@ -140,6 +142,7 @@ def run_diffoscope(parsed_args):
Config.general.max_report_size = parsed_args.max_report_size
Config.general.separate_file_diff_size = parsed_args.separate_file_diff_size
Config.general.fuzzy_threshold = parsed_args.fuzzy_threshold
+ Config.general.hide_profile = parsed_args.hide_profile
Config.general.new_file = parsed_args.new_file
if parsed_args.debug:
logger.setLevel(logging.DEBUG)
diff --git a/diffoscope/config.py b/diffoscope/config.py
index ff65558..f9bc7fa 100644
--- a/diffoscope/config.py
+++ b/diffoscope/config.py
@@ -33,6 +33,7 @@ class Config(object):
self._separate_file_diff_size = 200 * 2 ** 10 # 200kB
self._fuzzy_threshold = 60
self._new_file = False
+ self._hide_profile = None
@classproperty
def general(cls):
@@ -81,6 +82,14 @@ class Config(object):
self._fuzzy_threshold = value
@property
+ def hide_profile(self):
+ return self._hide_profile
+
+ @hide_profile.setter
+ def hide_profile(self, value):
+ self._hide_profile = value
+
+ @property
def new_file(self):
return self._new_file
diff --git a/diffoscope/presenters/html.py b/diffoscope/presenters/html.py
index 8830dc4..0a7ee00 100644
--- a/diffoscope/presenters/html.py
+++ b/diffoscope/presenters/html.py
@@ -506,6 +506,10 @@ def output_unified_diff(print_func, css_url, directory, unified_diff):
output_unified_diff_table(print_func, unified_diff)
def output_difference(difference, print_func, css_url, directory, parents):
+ if Config.general.hide_profile is not None:
+ if difference.source1 in Config.general.hide_profile:
+ logger.debug('output for %s is hidden', difference.source1)
+ return
logger.debug('html output for %s', difference.source1)
sources = parents + [difference.source1]
print_func(u"<div class='difference'>")
diff --git a/diffoscope/presenters/text.py b/diffoscope/presenters/text.py
index a9202b2..a14bde3 100644
--- a/diffoscope/presenters/text.py
+++ b/diffoscope/presenters/text.py
@@ -20,7 +20,7 @@
import sys
from diffoscope import logger
-
+from diffoscope.config import Config
def print_difference(difference, print_func):
if difference.comments:
@@ -33,7 +33,13 @@ def print_difference(difference, print_func):
def print_details(difference, print_func):
if not difference.details:
return
- for detail in difference.details:
+ difference_list = difference.details
+ if Config.general.hide_profile is not None:
+ for difference_detail in difference.details:
+ if difference_detail.source1 == Config.general.hide_profile:
+ difference_list.remove(difference_detail)
+
+ for detail in difference_list:
if detail.source1 == detail.source2:
print_func(u"├── %s" % detail.source1)
else:
@@ -47,6 +53,7 @@ def print_details(difference, print_func):
def output_text(difference, print_func):
try:
+ logger.debug('Output for %s is hidden', Config.general.hide_profile)
print_func("--- %s" % (difference.source1))
print_func("+++ %s" % (difference.source2))
print_difference(difference, print_func)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list