From 695a2b98df09043e86ce3f60b9f6544263fc2775 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Sat, 3 Nov 2012 01:08:08 +0100 Subject: [PATCH] Implemented support for XML output in the filtering module. --- filtering.py | 22 +++++++++++++++++++--- gitinspector.py | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/filtering.py b/filtering.py index 9e3e8ec..f0ee051 100644 --- a/filtering.py +++ b/filtering.py @@ -19,6 +19,7 @@ from __future__ import print_function import terminal +import textwrap __filters__ = [] __filtered_files__ = set() @@ -42,11 +43,26 @@ def set_filtered(file_name): return True return False -def output(): +__filtering_info_text__ = ("The following files were excluded from the statistics due to the" + "specified exclusion patterns") + +def output_html(): + print("HTML output not yet supported.") + +def output_text(): if __filtered_files__: - print("\nThe following files were excluded from the statistics due to the") - print("specified exclusion patterns:") + print("\n" + textwrap.fill(__filtering_info_text__ + ":", width=terminal.get_size()[0])) for i in __filtered_files__: (width, _) = terminal.get_size() print("...%s" % i[-width+3:] if len(i) > width else i) + +def output_xml(): + if __filtered_files__: + message_xml = "\t\t" + __filtering_info_text__ + "\n" + filtering_xml = "" + + for i in __filtered_files__: + filtering_xml += "\t\t\t" + i + "\n" + + print("\t\n" + message_xml + "\t\t\n" + filtering_xml + "\t\t\n\t") diff --git a/gitinspector.py b/gitinspector.py index 53c9062..4f864ca 100755 --- a/gitinspector.py +++ b/gitinspector.py @@ -68,7 +68,7 @@ class Runner: responsibilities.output_xml, self.hard) missing.output() - filtering.output() + format.call_output_function(filtering.output_html, filtering.output_text, filtering.output_xml) if self.list_file_types: format.call_output_function(extensions.output_html, extensions.output_text, extensions.output_xml)