From 00baf350a8ef8e4331e75911cfe1316313f47235 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Fri, 19 Oct 2012 02:01:10 +0200 Subject: [PATCH] Implemented support for XML output in the extensions module. --- extensions.py | 27 ++++++++++++++++++++++++--- gitinspector.py | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/extensions.py b/extensions.py index ff18903..17fa510 100644 --- a/extensions.py +++ b/extensions.py @@ -19,6 +19,7 @@ from __future__ import print_function import terminal +import textwrap __default_extensions__ = ["java", "c", "cpp", "h", "hpp", "py", "glsl", "rb", "js", "sql"] __extensions__ = __default_extensions__ @@ -35,10 +36,15 @@ def add_located(string): if len(string) > 0: __located_extensions__.add(string) -def output(): +__extensions_info_text__ = "The extensions below were found in the repository history" + +def output_html(): + print("HTML output not yet supported.") + +def output_text(): if __located_extensions__: - print("\nThe extensions below were found in the repository history") - print("(extensions used during statistical analysis are marked):") + print("\n" + textwrap.fill(__extensions_info_text__ + "\n(extensions used during statistical analysis are marked):", + width=terminal.get_size()[0])) for i in __located_extensions__: if i in __extensions__: @@ -46,3 +52,18 @@ def output(): else: print (i, end=" ") print("") + +def output_xml(): + if __located_extensions__: + message_xml = "\t\t" + __extensions_info_text__ + "\n" + used_extensions_xml = "" + unused_extensions_xml = "" + + for i in __located_extensions__: + if i in __extensions__: + used_extensions_xml += "\t\t\t" + i + "\n" + else: + unused_extensions_xml += "\t\t\t" + i + "\n" + + print("\t\n" + "\t\t\n" + used_extensions_xml + "\t\t\n" + + "\t\t\n" + unused_extensions_xml + "\t\t\n" + "\t") diff --git a/gitinspector.py b/gitinspector.py index fcdb3aa..f0977f7 100755 --- a/gitinspector.py +++ b/gitinspector.py @@ -69,7 +69,7 @@ class Runner: filtering.output() if self.list_file_types: - extensions.output() + format.call_output_function(extensions.output_html, extensions.output_text, extensions.output_xml) format.output_footer() os.chdir(previous_directory)