The responsibilities module no longer prints empty authors.

This commit is contained in:
Adam Waldenberg 2013-05-20 02:20:29 +02:00
parent fe3f067d6a
commit 128b8b3b56

View file

@ -52,32 +52,34 @@ class ResponsibilitiesOutput(Outputable):
print("\n" + textwrap.fill(__responsibilities_info_text__ + ":", width=terminal.get_size()[0])) print("\n" + textwrap.fill(__responsibilities_info_text__ + ":", width=terminal.get_size()[0]))
for i in sorted(set(i[0] for i in blame.get(self.hard).blames)): for i in sorted(set(i[0] for i in blame.get(self.hard).blames)):
print("\n" + i, "is mostly responsible for:")
responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True) responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True)
if responsibilities:
print("\n" + i, "is mostly responsible for:")
for j, entry in enumerate(responsibilities): for j, entry in enumerate(responsibilities):
(width, _) = terminal.get_size() (width, _) = terminal.get_size()
width -= 7 width -= 7
print(str(entry[0]).rjust(6), end=" ") print(str(entry[0]).rjust(6), end=" ")
print("...%s" % entry[1][-width+3:] if len(entry[1]) > width else entry[1]) print("...%s" % entry[1][-width+3:] if len(entry[1]) > width else entry[1])
if j >= 9: if j >= 9:
break break
def output_html(self): def output_html(self):
resp_xml = "<div><div class=\"box\">" resp_xml = "<div><div class=\"box\">"
resp_xml += "<p>" + __responsibilities_info_text__ + ".</p>" resp_xml += "<p>" + __responsibilities_info_text__ + ".</p>"
for i in sorted(set(i[0] for i in blame.get(self.hard).blames)): for i in sorted(set(i[0] for i in blame.get(self.hard).blames)):
resp_xml += "<h3>" + i + "is mostly responsible for</h3>"
responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True) responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True)
if responsibilities:
resp_xml += "<h3>" + i + "is mostly responsible for</h3>"
for j, entry in enumerate(responsibilities): for j, entry in enumerate(responsibilities):
resp_xml += "<p>" + entry[1] + " (" + str(entry[0]) + " eloc)</p>" resp_xml += "<p>" + entry[1] + " (" + str(entry[0]) + " eloc)</p>"
if j >= 9: if j >= 9:
break break
resp_xml += "</div></div>" resp_xml += "</div></div>"
print(resp_xml) print(resp_xml)
@ -87,21 +89,22 @@ class ResponsibilitiesOutput(Outputable):
resp_xml = "" resp_xml = ""
for i in sorted(set(i[0] for i in blame.get(self.hard).blames)): for i in sorted(set(i[0] for i in blame.get(self.hard).blames)):
resp_xml += "\t\t\t<author>\n"
resp_xml += "\t\t\t\t<name>" + i + "</name>\n"
resp_xml += "\t\t\t\t<files>\n"
responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True) responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True)
if responsibilities:
resp_xml += "\t\t\t<author>\n"
resp_xml += "\t\t\t\t<name>" + i + "</name>\n"
resp_xml += "\t\t\t\t<files>\n"
for j, entry in enumerate(responsibilities): for j, entry in enumerate(responsibilities):
resp_xml += "\t\t\t\t\t<file>\n" resp_xml += "\t\t\t\t\t<file>\n"
resp_xml += "\t\t\t\t\t\t<name>" + entry[1] + "</name>\n" resp_xml += "\t\t\t\t\t\t<name>" + entry[1] + "</name>\n"
resp_xml += "\t\t\t\t\t\t<rows>" + str(entry[0]) + "</rows>\n" resp_xml += "\t\t\t\t\t\t<rows>" + str(entry[0]) + "</rows>\n"
resp_xml += "\t\t\t\t\t</file>\n" resp_xml += "\t\t\t\t\t</file>\n"
if j >= 9: if j >= 9:
break break
resp_xml += "\t\t\t\t</files>\n" resp_xml += "\t\t\t\t</files>\n"
resp_xml += "\t\t\t</author>\n" resp_xml += "\t\t\t</author>\n"
print("\t<responsibilities>\n" + message_xml + "\t\t<authors>\n" + resp_xml + "\t\t</authors>\n\t</responsibilities>") print("\t<responsibilities>\n" + message_xml + "\t\t<authors>\n" + resp_xml + "\t\t</authors>\n\t</responsibilities>")