Commit 4b40a4b2 authored by Satyam Zode's avatar Satyam Zode

Add new feature to hide metadata generated by gzip

parent 2964df96
......@@ -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)
......
......@@ -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):
......@@ -80,6 +81,14 @@ class Config(object):
def fuzzy_threshold(self, value):
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
......
......@@ -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'>")
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment