Loading diffoscope/main.py +3 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ from .difference import Difference from .comparators import ComparatorManager from .external_tools import EXTERNAL_TOOLS from .presenters.html import JQUERY_SYSTEM_LOCATIONS from .presenters.formats import output_all from .presenters.formats import configure_presenters, output_all from .comparators.utils.compare import compare_root_paths logger = logging.getLogger(__name__) Loading Loading @@ -285,6 +285,7 @@ def run_diffoscope(parsed_args): Config().fuzzy_threshold = parsed_args.fuzzy_threshold Config().new_file = parsed_args.new_file Config().excludes = parsed_args.excludes presenter_config = configure_presenters(parsed_args) # Don't waste time computing visual differences if we won't use them. Config().compute_visual_diffs = any(( parsed_args.html_output, Loading @@ -304,7 +305,7 @@ def run_diffoscope(parsed_args): if difference is None and parsed_args.output_empty: difference = Difference(None, parsed_args.path1, parsed_args.path2) with profile('main', 'outputs'): output_all(difference, parsed_args, has_differences) output_all(presenter_config, difference, parsed_args, has_differences) return 1 if has_differences else 0 Loading diffoscope/presenters/formats.py +13 −12 Original line number Diff line number Diff line Loading @@ -31,14 +31,7 @@ from .restructuredtext import RestructuredTextPresenter logger = logging.getLogger(__name__) def output_all(difference, parsed_args, has_differences): """ Generate all known output formats. """ if difference is None: return def configure_presenters(parsed_args): FORMATS = { 'text': { 'klass': TextPresenter, Loading Loading @@ -66,14 +59,22 @@ def output_all(difference, parsed_args, has_differences): }, } result = {k: v for k, v in FORMATS.items() if v['target'] is not None} # If no output specified, default to printing --text output to stdout if not any(x['target'] for x in FORMATS.values()): if not result: parsed_args.text_output = FORMATS['text']['target'] = '-' result['text'] = FORMATS['text'] logger.debug( "Will generate the following formats: %s", ", ".join(result.keys()), ) return result for name, data in FORMATS.items(): if data['target'] is None: continue def output_all(config, difference, parsed_args, has_differences): for name, data in config.items(): logger.debug("Generating %r output at %r", name, data['target']) with profile('output', name): Loading Loading
diffoscope/main.py +3 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ from .difference import Difference from .comparators import ComparatorManager from .external_tools import EXTERNAL_TOOLS from .presenters.html import JQUERY_SYSTEM_LOCATIONS from .presenters.formats import output_all from .presenters.formats import configure_presenters, output_all from .comparators.utils.compare import compare_root_paths logger = logging.getLogger(__name__) Loading Loading @@ -285,6 +285,7 @@ def run_diffoscope(parsed_args): Config().fuzzy_threshold = parsed_args.fuzzy_threshold Config().new_file = parsed_args.new_file Config().excludes = parsed_args.excludes presenter_config = configure_presenters(parsed_args) # Don't waste time computing visual differences if we won't use them. Config().compute_visual_diffs = any(( parsed_args.html_output, Loading @@ -304,7 +305,7 @@ def run_diffoscope(parsed_args): if difference is None and parsed_args.output_empty: difference = Difference(None, parsed_args.path1, parsed_args.path2) with profile('main', 'outputs'): output_all(difference, parsed_args, has_differences) output_all(presenter_config, difference, parsed_args, has_differences) return 1 if has_differences else 0 Loading
diffoscope/presenters/formats.py +13 −12 Original line number Diff line number Diff line Loading @@ -31,14 +31,7 @@ from .restructuredtext import RestructuredTextPresenter logger = logging.getLogger(__name__) def output_all(difference, parsed_args, has_differences): """ Generate all known output formats. """ if difference is None: return def configure_presenters(parsed_args): FORMATS = { 'text': { 'klass': TextPresenter, Loading Loading @@ -66,14 +59,22 @@ def output_all(difference, parsed_args, has_differences): }, } result = {k: v for k, v in FORMATS.items() if v['target'] is not None} # If no output specified, default to printing --text output to stdout if not any(x['target'] for x in FORMATS.values()): if not result: parsed_args.text_output = FORMATS['text']['target'] = '-' result['text'] = FORMATS['text'] logger.debug( "Will generate the following formats: %s", ", ".join(result.keys()), ) return result for name, data in FORMATS.items(): if data['target'] is None: continue def output_all(config, difference, parsed_args, has_differences): for name, data in config.items(): logger.debug("Generating %r output at %r", name, data['target']) with profile('output', name): Loading