Implemented support for XML output in the version module.

This commit is contained in:
Adam Waldenberg 2012-10-18 15:34:16 +02:00
parent fb0b29c6c5
commit ed92376d35
2 changed files with 12 additions and 5 deletions

View file

@ -100,7 +100,7 @@ if __name__ == "__main__":
elif o in("-r", "--responsibilities"):
__run__.responsibilities = True
elif o in("--version"):
version.output()
format.call_output_function(version.output_html, version.output_text, version.output_xml)
sys.exit(0)
elif o in("--grading"):
__run__.include_metrics = True

View file

@ -17,8 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.
"""gitinspector {0}
Copyright © 2012 Ejwa Software. All rights reserved.
"""Copyright © 2012 Ejwa Software. All rights reserved.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
@ -29,5 +28,13 @@ from __future__ import print_function
__version__ = "0.1.0"
def output():
print(__doc__.format(__version__))
def output_html(string, _):
print("HTML output not yet supported.")
def output_text(_):
print("gitinspector {0}\n".format(__version__) + __doc__)
def output_xml(string, _):
license_text = "\t\t" + __doc__.replace("\n", "\n\t\t")
print(string.format("\n\t<version>" + __version__ + "</version>\n" +
"\t<license-text>\n" + license_text + "\n\t</license-text>\n"))