diff --git a/gitinspector.py b/gitinspector.py
index 12b3e12..31d8fe8 100755
--- a/gitinspector.py
+++ b/gitinspector.py
@@ -57,7 +57,8 @@ class Runner:
format.call_output_function(blame.output_html, blame.output_text, blame.output_xml, self.hard)
if self.timeline:
- timeline.output(changes.get(self.hard), self.useweeks)
+ format.call_output_function(timeline.output_html, timeline.output_text, timeline.output_xml,
+ changes.get(self.hard), self.useweeks)
if self.include_metrics:
metrics.output()
diff --git a/timeline.py b/timeline.py
index 403617b..40cc5ef 100644
--- a/timeline.py
+++ b/timeline.py
@@ -20,6 +20,7 @@
from __future__ import print_function
import datetime
import terminal
+import textwrap
class TimelineData:
def __init__(self, changes, useweeks):
@@ -90,7 +91,12 @@ class TimelineData:
def is_author_in_period(self, period, author):
return self.entries.get((author, period), None) != None
-def __output_row__(timeline_data, periods, names):
+__timeline_info_text__ = "The following history timeline has been gathered from the repository"
+
+def output_html(changes, useweeks):
+ print("HTML output not yet supported.")
+
+def __output_row__text__(timeline_data, periods, names):
print("\n" + terminal.__bold__ + "Author".ljust(20), end=" ")
for period in periods:
@@ -108,9 +114,9 @@ def __output_row__(timeline_data, periods, names):
len(signs_str) == 0 else signs_str).rjust(10), end=" ")
print("")
-def output(changes, useweeks):
+def output_text(changes, useweeks):
if changes.get_commits():
- print("\nThe following history timeline has been gathered from the repository:")
+ print("\n" + textwrap.fill(__timeline_info_text__ + ":", width=terminal.get_size()[0]))
timeline_data = TimelineData(changes, useweeks)
periods = timeline_data.get_periods()
@@ -119,4 +125,34 @@ def output(changes, useweeks):
max_periods_per_row = int((width - 21) / 11)
for i in range(0, len(periods), max_periods_per_row):
- __output_row__(timeline_data, periods[i:i+max_periods_per_row], names)
+ __output_row__text__(timeline_data, periods[i:i+max_periods_per_row], names)
+
+def output_xml(changes, useweeks):
+ if changes.get_commits():
+ message_xml = "\t\t" + __timeline_info_text__ + "\n"
+ timeline_xml = ""
+ periods_xml = "\t\t\n".format("week" if useweeks else "month")
+
+ timeline_data = TimelineData(changes, useweeks)
+ periods = timeline_data.get_periods()
+ names = timeline_data.get_authors()
+
+ for period in periods:
+ name_xml = "\t\t\t\t" + str(period) + "\n"
+ authors_xml = ""
+
+ for name in names:
+ authors_xml += "\t\t\t\t\n"
+ multiplier = timeline_data.get_multiplier(period, 24)
+ signs = timeline_data.get_author_signs_in_period(name, period, multiplier)
+ signs_str = (signs[1] * "-" + signs[0] * "+")
+
+ if not len(signs_str) == 0:
+ authors_xml += "\t\t\t\t\t\n\t\t\t\t\t\t" + name + "\n"
+ authors_xml += "\t\t\t\t\t\t" + signs_str + "\n\t\t\t\t\t\n"
+
+ authors_xml += "\t\t\t\t\n"
+
+ timeline_xml += "\t\t\t\n" + name_xml + authors_xml + "\t\t\t\n"
+
+ print("\t\n" + message_xml + periods_xml + timeline_xml + "\t\t\n\t")