From bfde70db9114fef892a2f2445f23d7733c7048e1 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Tue, 24 Nov 2015 21:02:32 +0100 Subject: [PATCH] Include author email in JSON and HTML outputs (Fixes #85). --- gitinspector/output/blameoutput.py | 10 ++++++---- gitinspector/output/changesoutput.py | 16 +++++++++++----- gitinspector/output/responsibilitiesoutput.py | 2 ++ gitinspector/output/timelineoutput.py | 2 ++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/gitinspector/output/blameoutput.py b/gitinspector/output/blameoutput.py index 677b432..cca93e5 100644 --- a/gitinspector/output/blameoutput.py +++ b/gitinspector/output/blameoutput.py @@ -102,6 +102,7 @@ class BlameOutput(Outputable): author_email = self.changes.get_latest_email_by_author(i[0]) name_xml = "\t\t\t\t\"name\": \"" + i[0] + "\",\n" + email_json = "\t\t\t\t\"email\": \"" + author_email + "\",\n" gravatar_xml = "\t\t\t\t\"gravatar\": \"" + gravatar.get_url(author_email) + "\",\n" rows_xml = "\t\t\t\t\"rows\": " + str(i[1].rows) + ",\n" stability_xml = ("\t\t\t\t\"stability\": " + "{0:.1f}".format(Blame.get_stability(i[0], i[1].rows, @@ -109,8 +110,8 @@ class BlameOutput(Outputable): age_xml = ("\t\t\t\t\"age\": " + "{0:.1f}".format(float(i[1].skew) / i[1].rows) + ",\n") percentage_in_comments_xml = ("\t\t\t\t\"percentage_in_comments\": " + "{0:.2f}".format(100.0 * i[1].comments / i[1].rows) + "\n") - blame_xml += ("{\n" + name_xml + gravatar_xml + rows_xml + stability_xml + age_xml + - percentage_in_comments_xml + "\t\t\t},") + blame_xml += ("{\n" + name_xml + email_json + gravatar_xml + rows_xml + stability_xml + age_xml + + percentage_in_comments_xml + "\t\t\t},") else: blame_xml = blame_xml[:-1] @@ -139,6 +140,7 @@ class BlameOutput(Outputable): author_email = self.changes.get_latest_email_by_author(i[0]) name_xml = "\t\t\t\t" + i[0] + "\n" + email_xml = "\t\t\t\t" + author_email + "\n" gravatar_xml = "\t\t\t\t" + gravatar.get_url(author_email) + "\n" rows_xml = "\t\t\t\t" + str(i[1].rows) + "\n" stability_xml = ("\t\t\t\t" + "{0:.1f}".format(Blame.get_stability(i[0], i[1].rows, @@ -146,7 +148,7 @@ class BlameOutput(Outputable): age_xml = ("\t\t\t\t" + "{0:.1f}".format(float(i[1].skew) / i[1].rows) + "\n") percentage_in_comments_xml = ("\t\t\t\t" + "{0:.2f}".format(100.0 * i[1].comments / i[1].rows) + "\n") - blame_xml += ("\t\t\t\n" + name_xml + gravatar_xml + rows_xml + stability_xml + age_xml + - percentage_in_comments_xml + "\t\t\t\n") + blame_xml += ("\t\t\t\n" + name_xml + email_xml + gravatar_xml + rows_xml + stability_xml + + age_xml + percentage_in_comments_xml + "\t\t\t\n") print("\t\n" + message_xml + "\t\t\n" + blame_xml + "\t\t\n\t") diff --git a/gitinspector/output/changesoutput.py b/gitinspector/output/changesoutput.py index 7a6b773..c7cd021 100644 --- a/gitinspector/output/changesoutput.py +++ b/gitinspector/output/changesoutput.py @@ -108,16 +108,19 @@ class ChangesOutput(Outputable): changes_xml = "" for i in sorted(authorinfo_list): + author_email = self.changes.get_latest_email_by_author(i) authorinfo = authorinfo_list.get(i) + percentage = 0 if total_changes == 0 else (authorinfo.insertions + authorinfo.deletions) / total_changes * 100 name_xml = "\t\t\t\t\"name\": \"" + i + "\",\n" - gravatar_xml = "\t\t\t\t\"gravatar\": \"" + gravatar.get_url(self.changes.get_latest_email_by_author(i)) + "\",\n" + email_json = "\t\t\t\t\"email\": \"" + author_email + "\",\n" + gravatar_xml = "\t\t\t\t\"gravatar\": \"" + gravatar.get_url(author_email) + "\",\n" commits_xml = "\t\t\t\t\"commits\": " + str(authorinfo.commits) + ",\n" insertions_xml = "\t\t\t\t\"insertions\": " + str(authorinfo.insertions) + ",\n" deletions_xml = "\t\t\t\t\"deletions\": " + str(authorinfo.deletions) + ",\n" percentage_xml = "\t\t\t\t\"percentage_of_changes\": " + "{0:.2f}".format(percentage) + "\n" - changes_xml += ("{\n" + name_xml + gravatar_xml + commits_xml + insertions_xml + + changes_xml += ("{\n" + name_xml + email_json + gravatar_xml + commits_xml + insertions_xml + deletions_xml + percentage_xml + "\t\t\t}") changes_xml += "," else: @@ -166,17 +169,20 @@ class ChangesOutput(Outputable): changes_xml = "" for i in sorted(authorinfo_list): + author_email = self.changes.get_latest_email_by_author(i) authorinfo = authorinfo_list.get(i) + percentage = 0 if total_changes == 0 else (authorinfo.insertions + authorinfo.deletions) / total_changes * 100 name_xml = "\t\t\t\t" + i + "\n" - gravatar_xml = "\t\t\t\t" + gravatar.get_url(self.changes.get_latest_email_by_author(i)) + "\n" + email_xml = "\t\t\t\t" + author_email + "\n" + gravatar_xml = "\t\t\t\t" + gravatar.get_url(author_email) + "\n" commits_xml = "\t\t\t\t" + str(authorinfo.commits) + "\n" insertions_xml = "\t\t\t\t" + str(authorinfo.insertions) + "\n" deletions_xml = "\t\t\t\t" + str(authorinfo.deletions) + "\n" percentage_xml = "\t\t\t\t" + "{0:.2f}".format(percentage) + "\n" - changes_xml += ("\t\t\t\n" + name_xml + gravatar_xml + commits_xml + insertions_xml + - deletions_xml + percentage_xml + "\t\t\t\n") + changes_xml += ("\t\t\t\n" + name_xml + email_xml + gravatar_xml + commits_xml + + insertions_xml + deletions_xml + percentage_xml + "\t\t\t\n") print("\t\n" + message_xml + "\t\t\n" + changes_xml + "\t\t\n\t") else: diff --git a/gitinspector/output/responsibilitiesoutput.py b/gitinspector/output/responsibilitiesoutput.py index d70ba4d..d15bce1 100644 --- a/gitinspector/output/responsibilitiesoutput.py +++ b/gitinspector/output/responsibilitiesoutput.py @@ -94,6 +94,7 @@ class ResponsibilitiesOutput(Outputable): resp_xml += "{\n" resp_xml += "\t\t\t\t\"name\": \"" + i + "\",\n" + resp_xml += "\t\t\t\t\"email\": \"" + author_email + "\",\n" resp_xml += "\t\t\t\t\"gravatar\": \"" + gravatar.get_url(author_email) + "\",\n" resp_xml += "\t\t\t\t\"files\": [\n\t\t\t\t" @@ -124,6 +125,7 @@ class ResponsibilitiesOutput(Outputable): resp_xml += "\t\t\t\n" resp_xml += "\t\t\t\t" + i + "\n" + resp_xml += "\t\t\t\t" + author_email + "\n" resp_xml += "\t\t\t\t" + gravatar.get_url(author_email) + "\n" resp_xml += "\t\t\t\t\n" diff --git a/gitinspector/output/timelineoutput.py b/gitinspector/output/timelineoutput.py index ab35d44..6be4293 100644 --- a/gitinspector/output/timelineoutput.py +++ b/gitinspector/output/timelineoutput.py @@ -157,6 +157,7 @@ class TimelineOutput(Outputable): signs_str = "." authors_xml += "{\n\t\t\t\t\t\"name\": \"" + name[0] + "\",\n" + authors_xml += "\t\t\t\t\t\"email\": \"" + name[1] + "\",\n" authors_xml += "\t\t\t\t\t\"gravatar\": \"" + gravatar.get_url(name[1]) + "\",\n" authors_xml += "\t\t\t\t\t\"work\": \"" + signs_str + "\"\n\t\t\t\t}," else: @@ -195,6 +196,7 @@ class TimelineOutput(Outputable): signs_str = "." authors_xml += "\t\t\t\t\t\n\t\t\t\t\t\t" + name[0] + "\n" + authors_xml += "\t\t\t\t\t\t" + name[1] + "\n" authors_xml += "\t\t\t\t\t\t" + gravatar.get_url(name[1]) + "\n" authors_xml += "\t\t\t\t\t\t" + signs_str + "\n\t\t\t\t\t\n"