From 128b8b3b5603c219449c1111b1df6e67550569ea Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Mon, 20 May 2013 02:20:29 +0200 Subject: [PATCH] The responsibilities module no longer prints empty authors. --- responsibilities.py | 53 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/responsibilities.py b/responsibilities.py index e9fc012..3416340 100644 --- a/responsibilities.py +++ b/responsibilities.py @@ -52,32 +52,34 @@ class ResponsibilitiesOutput(Outputable): 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)): - print("\n" + i, "is mostly responsible for:") 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): - (width, _) = terminal.get_size() - width -= 7 + for j, entry in enumerate(responsibilities): + (width, _) = terminal.get_size() + width -= 7 - print(str(entry[0]).rjust(6), end=" ") - print("...%s" % entry[1][-width+3:] if len(entry[1]) > width else entry[1]) + print(str(entry[0]).rjust(6), end=" ") + print("...%s" % entry[1][-width+3:] if len(entry[1]) > width else entry[1]) - if j >= 9: - break + if j >= 9: + break def output_html(self): resp_xml = "
" resp_xml += "

" + __responsibilities_info_text__ + ".

" for i in sorted(set(i[0] for i in blame.get(self.hard).blames)): - resp_xml += "

" + i + "is mostly responsible for

" responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True) + if responsibilities: + resp_xml += "

" + i + "is mostly responsible for

" - for j, entry in enumerate(responsibilities): - resp_xml += "

" + entry[1] + " (" + str(entry[0]) + " eloc)

" + for j, entry in enumerate(responsibilities): + resp_xml += "

" + entry[1] + " (" + str(entry[0]) + " eloc)

" - if j >= 9: - break + if j >= 9: + break resp_xml += "
" print(resp_xml) @@ -87,21 +89,22 @@ class ResponsibilitiesOutput(Outputable): resp_xml = "" for i in sorted(set(i[0] for i in blame.get(self.hard).blames)): - resp_xml += "\t\t\t\n" - resp_xml += "\t\t\t\t" + i + "\n" - resp_xml += "\t\t\t\t\n" responsibilities = sorted(((i[1], i[0]) for i in Responsibilities.get(self.hard, i)), reverse=True) + if responsibilities: + resp_xml += "\t\t\t\n" + resp_xml += "\t\t\t\t" + i + "\n" + resp_xml += "\t\t\t\t\n" - for j, entry in enumerate(responsibilities): - resp_xml += "\t\t\t\t\t\n" - resp_xml += "\t\t\t\t\t\t" + entry[1] + "\n" - resp_xml += "\t\t\t\t\t\t" + str(entry[0]) + "\n" - resp_xml += "\t\t\t\t\t\n" + for j, entry in enumerate(responsibilities): + resp_xml += "\t\t\t\t\t\n" + resp_xml += "\t\t\t\t\t\t" + entry[1] + "\n" + resp_xml += "\t\t\t\t\t\t" + str(entry[0]) + "\n" + resp_xml += "\t\t\t\t\t\n" - if j >= 9: - break + if j >= 9: + break - resp_xml += "\t\t\t\t\n" - resp_xml += "\t\t\t\n" + resp_xml += "\t\t\t\t\n" + resp_xml += "\t\t\t\n" print("\t\n" + message_xml + "\t\t\n" + resp_xml + "\t\t\n\t")