Implemented support for XML output in the filtering module.

This commit is contained in:
Adam Waldenberg 2012-11-03 01:08:08 +01:00
parent 5b8ce8c1e8
commit 695a2b98df
2 changed files with 20 additions and 4 deletions

View file

@ -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<message>" + __filtering_info_text__ + "</message>\n"
filtering_xml = ""
for i in __filtered_files__:
filtering_xml += "\t\t\t<file>" + i + "</file>\n"
print("\t<filering>\n" + message_xml + "\t\t<files>\n" + filtering_xml + "\t\t</files>\n\t</filtering>")

View file

@ -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)