Empty rows are now skipped in the timeline output.

In practice, this means that whenever an author is not part of a
collection of periods he will not be printed out.

This cleans up the output and also speeds up analysis.
This commit is contained in:
Adam Waldenberg 2013-05-06 13:30:58 +02:00
parent 2dd4c2c4ff
commit 0c6358324d
1 changed files with 28 additions and 18 deletions

View File

@ -95,6 +95,12 @@ class TimelineData:
def is_author_in_period(self, period, author): def is_author_in_period(self, period, author):
return self.entries.get((author, period), None) != None return self.entries.get((author, period), None) != None
def is_author_in_periods(self, periods, author):
for period in periods:
if self.is_author_in_period(period, author):
return True
return False
__timeline_info_text__ = "The following history timeline has been gathered from the repository" __timeline_info_text__ = "The following history timeline has been gathered from the repository"
def __output_row__text__(timeline_data, periods, names): def __output_row__text__(timeline_data, periods, names):
@ -106,14 +112,15 @@ def __output_row__text__(timeline_data, periods, names):
print(terminal.__normal__) print(terminal.__normal__)
for name in names: for name in names:
print(name.ljust(20)[0:20], end=" ") if timeline_data.is_author_in_periods(periods, name):
for period in periods: print(name.ljust(20)[0:20], end=" ")
multiplier = timeline_data.get_multiplier(period, 9) for period in periods:
signs = timeline_data.get_author_signs_in_period(name, period, multiplier) multiplier = timeline_data.get_multiplier(period, 9)
signs_str = (signs[1] * "-" + signs[0] * "+") signs = timeline_data.get_author_signs_in_period(name, period, multiplier)
print (("." if timeline_data.is_author_in_period(period, name) and signs_str = (signs[1] * "-" + signs[0] * "+")
len(signs_str) == 0 else signs_str).rjust(10), end=" ") print (("." if timeline_data.is_author_in_period(period, name) and
print("") len(signs_str) == 0 else signs_str).rjust(10), end=" ")
print("")
print(terminal.__bold__ + "Modified Rows:".ljust(20) + terminal.__normal__, end=" ") print(terminal.__bold__ + "Modified Rows:".ljust(20) + terminal.__normal__, end=" ")
@ -130,18 +137,21 @@ def __output_row__html__(timeline_data, periods, names):
timeline_xml += "<th>" + str(period) + "</th>" timeline_xml += "<th>" + str(period) + "</th>"
timeline_xml += "</tr></thead><tbody>" timeline_xml += "</tr></thead><tbody>"
i = 0
for i, name in enumerate(names): for name in names:
timeline_xml += "<tr" + (" class=\"odd\">" if i % 2 == 1 else ">") if timeline_data.is_author_in_periods(periods, name):
timeline_xml += "<td>" + name + "</td>" timeline_xml += "<tr" + (" class=\"odd\">" if i % 2 == 1 else ">")
for period in periods: timeline_xml += "<td>" + name + "</td>"
multiplier = timeline_data.get_multiplier(period, 14) for period in periods:
signs = timeline_data.get_author_signs_in_period(name, period, multiplier) multiplier = timeline_data.get_multiplier(period, 14)
signs_str = (signs[1] * "<div class=\"remove\">&nbsp;</div>" + signs[0] * "<div class=\"insert\">&nbsp;</div>") signs = timeline_data.get_author_signs_in_period(name, period, multiplier)
signs_str = (signs[1] * "<div class=\"remove\">&nbsp;</div>" + signs[0] * "<div class=\"insert\">&nbsp;</div>")
timeline_xml += "<td>" + ("." if timeline_data.is_author_in_period(period, name) and len(signs_str) == 0 else signs_str) timeline_xml += "<td>" + ("." if timeline_data.is_author_in_period(period, name) and len(signs_str) == 0 else signs_str)
timeline_xml += "</td>" timeline_xml += "</td>"
timeline_xml += "</tr>" timeline_xml += "</tr>"
i = i + 1
timeline_xml += "<tfoot><tr><td><strong>Modified Rows:</strong></td>" timeline_xml += "<tfoot><tr><td><strong>Modified Rows:</strong></td>"