diff options
author | Germán Póo-Caamaño <gpoo@gnome.org> | 2011-06-24 00:17:30 -0700 |
---|---|---|
committer | Germán Póo-Caamaño <gpoo@gnome.org> | 2011-06-24 00:17:30 -0700 |
commit | b2770f20b9a76a86fbec3f7be10b35c9ea1f3637 (patch) | |
tree | ebefe676226e9b377df14856d75bc89186af7011 | |
parent | 19b718ef41f87f348ac45a90a5c4096ccbd0f7db (diff) |
Added reports by file types
Added first attempt for reporting by file type:
- A general report
- A report aggregated by file type and contributor
- A report aggregated by contributor and file type
Signed-off-by: Germán Póo-Caamaño <gpoo@gnome.org>
-rwxr-xr-x | gitdm | 9 | ||||
-rw-r--r-- | reports.py | 44 |
2 files changed, 51 insertions, 2 deletions
@@ -41,6 +41,7 @@ CFName = 'gitdm.config' DirName = '' Aggregate = 'month' Numstat = 0 +ReportByFileType = 0 # # Options: @@ -66,8 +67,9 @@ def ParseOpts (): global MapUnknown, DevReports global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB global CFName, CSVFile, CSVPrefix,DirName, Aggregate, Numstat + global ReportByFileType - opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:suwx:z') + opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:no:p:r:stuwx:z') for opt in opts: if opt[0] == '-a': AkpmOverLt = 1 @@ -94,6 +96,8 @@ def ParseOpts (): FileFilter = re.compile (opt[1]) elif opt[0] == '-s': AuthorSOBs = 0 + elif opt[0] == '-t': + ReportByFileType = 1 elif opt[0] == '-u': MapUnknown = 1 elif opt[0] == '-x': @@ -485,3 +489,6 @@ if CSVFile: if DevReports: reports.DevReports (hlist, TotalChanged, CSCount, TotalRemoved) reports.EmplReports (elist, TotalChanged, CSCount) + +if ReportByFileType and Numstat: + reports.ReportByFileType (hlist) @@ -340,4 +340,46 @@ def EmplReports (elist, totalchanged, cscount): ReportByELChanged (elist, totalchanged) ReportByESOBs (elist) ReportByEHackers (elist) - + +def ReportByFileType (hacker_list): + total = {} + total_by_hacker = {} + + BeginReport ('Developer contributions by type') + for h in hacker_list: + by_hacker = {} + for patch in h.patches: + # Get a summary by hacker + for (filetype, (added, removed)) in patch.filetypes.iteritems(): + if by_hacker.has_key(filetype): + by_hacker[filetype][patch.ADDED] += added + by_hacker[filetype][patch.REMOVED] += removed + else: + by_hacker[filetype] = [added, removed] + + # Update the totals + if total.has_key(filetype): + total[filetype][patch.ADDED] += added + total[filetype][patch.REMOVED] += removed + else: + total[filetype] = [added, removed, []] + + # Print a summary by hacker + print h.name + for filetype, counters in by_hacker.iteritems(): + print '\t', filetype, counters + h_added = by_hacker[filetype][patch.ADDED] + h_removed = by_hacker[filetype][patch.REMOVED] + total[filetype][2].append ([h.name, h_added, h_removed]) + + # Print the global summary + BeginReport ('Contributions by type and developers') + for filetype, (added, removed, hackers) in total.iteritems(): + print filetype, added, removed + for h, h_added, h_removed in hackers: + print '\t%s: [%d, %d]' % (h, h_added, h_removed) + + # Print the very global summary + BeginReport ('General contributions by type') + for filetype, (added, removed, hackers) in total.iteritems(): + print filetype, added, removed |