Commit 7184050f606d70dad62f5ecd4722e30e5aff7e3c
- Diff rendering mode:
- inline
- side by side
csvdump.py
(43 / 1)
|   | |||
| 28 | 28 | stat = PeriodCommitHash[authdatekey] | |
| 29 | 29 | stat.accumulate (p) | |
| 30 | 30 | ||
| 31 | ChangeSets = [] | ||
| 32 | FileTypes = [] | ||
| 33 | |||
| 34 | def store_patch(patch): | ||
| 35 | if not patch.merge: | ||
| 36 | employer = patch.author.emailemployer(patch.email, patch.date) | ||
| 37 | employer = employer.name.replace('"', '.').replace ('\\', '.') | ||
| 38 | author = patch.author.name.replace ('"', '.').replace ('\\', '.') | ||
| 39 | author = patch.author.name.replace ("'", '.') | ||
| 40 | try: | ||
| 41 | domain = patch.email.split('@')[1] | ||
| 42 | except: | ||
| 43 | domain = patch.email | ||
| 44 | ChangeSets.append([patch.commit, str(patch.date), | ||
| 45 | patch.email, domain, author, employer, | ||
| 46 | patch.added, patch.removed]) | ||
| 47 | for (filetype, (added, removed)) in patch.filetypes.iteritems(): | ||
| 48 | FileTypes.append([patch.commit, filetype, added, removed]) | ||
| 49 | |||
| 50 | |||
| 51 | def save_csv (prefix='data'): | ||
| 52 | # Dump the ChangeSets | ||
| 53 | if len(ChangeSets) > 0: | ||
| 54 | fd = open('%s-changesets.csv' % prefix, 'w') | ||
| 55 | writer = csv.writer (fd, quoting=csv.QUOTE_NONNUMERIC) | ||
| 56 | writer.writerow (['Commit', 'Date', 'Domain', | ||
| 57 | 'Email', 'Name', 'Affliation', | ||
| 58 | 'Added', 'Removed']) | ||
| 59 | for commit in ChangeSets: | ||
| 60 | writer.writerow(commit) | ||
| 61 | |||
| 62 | # Dump the file types | ||
| 63 | if len(FileTypes) > 0: | ||
| 64 | fd = open('%s-filetypes.csv' % prefix, 'w') | ||
| 65 | writer = csv.writer (fd, quoting=csv.QUOTE_NONNUMERIC) | ||
| 66 | |||
| 67 | writer.writerow (['Commit', 'Type', 'Added', 'Removed']) | ||
| 68 | for commit in FileTypes: | ||
| 69 | writer.writerow(commit) | ||
| 70 | |||
| 71 | |||
| 72 | |||
| 31 | 73 | def OutputCSV (file): | |
| 32 | 74 | if file is None: | |
| 33 | 75 | return | |
| … | … | ||
| 83 | 83 | writer.writerow ([author_name, stat.email, empl_name, stat.date, | |
| 84 | 84 | stat.added, stat.removed]) | |
| 85 | 85 | ||
| 86 | __all__ = [ 'OutputCSV' ] | ||
| 86 | __all__ = [ 'AccumulatePatch', 'OutputCSV', 'store_patch' ] |
gitdm
(12 / 4)
|   | |||
| 29 | 29 | AuthorSOBs = 1 | |
| 30 | 30 | FileFilter = None | |
| 31 | 31 | CSVFile = None | |
| 32 | CSVPrefix = None | ||
| 32 | 33 | AkpmOverLt = 0 | |
| 33 | 34 | DumpDB = 0 | |
| 34 | 35 | CFName = 'gitdm.config' | |
| … | … | ||
| 43 | 43 | # -h hfile HTML output to hfile | |
| 44 | 44 | # -l count Maximum length for output lists | |
| 45 | 45 | # -o file File for text output | |
| 46 | # -p prefix Prefix for CSV output | ||
| 46 | 47 | # -r pattern Restrict to files matching pattern | |
| 47 | 48 | # -s Ignore author SOB lines | |
| 48 | 49 | # -u Map unknown employers to '(Unknown)' | |
| … | … | ||
| 53 | 53 | def ParseOpts (): | |
| 54 | 54 | global MapUnknown, DevReports | |
| 55 | 55 | global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB | |
| 56 | global CFName, CSVFile | ||
| 56 | global CFName, CSVFile, CSVPrefix | ||
| 57 | 57 | ||
| 58 | opts, rest = getopt.getopt (sys.argv[1:], 'adc:Dh:l:o:r:sux:z') | ||
| 58 | opts, rest = getopt.getopt (sys.argv[1:], 'adc:Dh:l:o:p:r:sux:z') | ||
| 59 | 59 | for opt in opts: | |
| 60 | 60 | if opt[0] == '-a': | |
| 61 | 61 | AkpmOverLt = 1 | |
| … | … | ||
| 71 | 71 | reports.SetMaxList (int (opt[1])) | |
| 72 | 72 | elif opt[0] == '-o': | |
| 73 | 73 | reports.SetOutput (open (opt[1], 'w')) | |
| 74 | elif opt[0] == '-p': | ||
| 75 | CSVPrefix = opt[1] | ||
| 74 | 76 | elif opt[0] == '-r': | |
| 75 | 77 | print 'Filter on "%s"' % (opt[1]) | |
| 76 | 78 | FileFilter = re.compile (opt[1]) | |
| … | … | ||
| 362 | 362 | hacker.addreport (p) | |
| 363 | 363 | CSCount += 1 | |
| 364 | 364 | csvdump.AccumulatePatch (p) | |
| 365 | csvdump.store_patch (p) | ||
| 365 | 366 | print >> sys.stderr, 'Grabbing changesets...done ' | |
| 366 | 367 | ||
| 367 | 368 | if DumpDB: | |
| … | … | ||
| 390 | 390 | PrintDateStats () | |
| 391 | 391 | sys.exit(0) | |
| 392 | 392 | ||
| 393 | csvdump.OutputCSV (CSVFile) | ||
| 394 | if CSVFile is not None: | ||
| 393 | if CSVPrefix: | ||
| 394 | csvdump.save_csv (CSVPrefix) | ||
| 395 | |||
| 396 | if CSVFile: | ||
| 397 | csvdump.OutputCSV (CSVFile) | ||
| 395 | 398 | CSVFile.close () | |
| 396 | 399 | ||
| 397 | 400 | if DevReports: |
Comments
Add a new comment:
Login or create an account to post a comment
Add your comment
Please log in to comment

