forked from markmc/openstack-gitdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lpdm
executable file
·132 lines (114 loc) · 3.22 KB
/
lpdm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/pypy
#-*- coding:utf-8 -*-
#
#
# This code is part of the LWN git data miner.
#
# Copyright 2007-11 Eklektix, Inc.
# Copyright 2007-11 Jonathan Corbet <corbet@lwn.net>
# Copyright 2011 Germán Póo-Caamaño <gpoo@gnome.org>
#
# This file may be distributed under the terms of the GNU General
# Public License, version 2.
import database, ConfigFile, reports
import getopt, datetime
import sys
Today = datetime.date.today()
#
# Control options.
#
MapUnknown = 0
DevReports = 1
DumpDB = 0
CFName = 'gitdm.config'
DirName = ''
#
# Options:
#
# -b dir Specify the base directory to fetch the configuration files
# -c cfile Specify a configuration file
# -d Output individual developer stats
# -h hfile HTML output to hfile
# -l count Maximum length for output lists
# -o file File for text output
# -p prefix Prefix for CSV output
# -s Ignore author SOB lines
# -u Map unknown employers to '(Unknown)'
# -z Dump out the hacker database at completion
def ParseOpts ():
global MapUnknown, DevReports
global DumpDB
global CFName, DirName, Aggregate
opts, rest = getopt.getopt (sys.argv[1:], 'b:dc:h:l:o:uz')
for opt in opts:
if opt[0] == '-b':
DirName = opt[1]
elif opt[0] == '-c':
CFName = opt[1]
elif opt[0] == '-d':
DevReports = 0
elif opt[0] == '-h':
reports.SetHTMLOutput (open (opt[1], 'w'))
elif opt[0] == '-l':
reports.SetMaxList (int (opt[1]))
elif opt[0] == '-o':
reports.SetOutput (open (opt[1], 'w'))
elif opt[0] == '-u':
MapUnknown = 1
elif opt[0] == '-z':
DumpDB = 1
def LookupStoreHacker (name, email):
email = database.RemapEmail (email)
h = database.LookupEmail (email)
if h: # already there
return h
elist = database.LookupEmployer (email, MapUnknown)
h = database.LookupName (name)
if h: # new email
h.addemail (email, elist)
return h
return database.StoreHacker(name, elist, email)
class Bug:
def __init__(self, id, owner, date, emails):
self.id = id
self.owner = LookupStoreHacker('Unknown hacker', 'unknown@hacker.net')
self.date = date
for email in emails:
self.owner = LookupStoreHacker(owner, email)
@classmethod
def parse(cls, line):
split = line.split()
return cls(split[0], split[1], split[2], split[3:])
#
# Here starts the real program.
#
ParseOpts ()
#
# Read the config files.
#
ConfigFile.ConfigFile (CFName, DirName)
bugs = [Bug.parse(l) for l in sys.stdin]
for bug in bugs:
bug.owner.addbugfixed(bug)
empl = bug.owner.emailemployer(bug.owner.email[0], ConfigFile.ParseDate(bug.date))
empl.AddBug(bug)
if DumpDB:
database.DumpDB ()
database.MixVirtuals ()
#
# Say something
#
hlist = database.AllHackers ()
elist = database.AllEmployers ()
ndev = nempl = 0
for h in hlist:
if len (h.bugsfixed) > 0:
ndev += 1
for e in elist:
if len(e.bugsfixed) > 0:
nempl += 1
reports.Write ('Processed %d bugs from %d developers\n' % (len(bugs), ndev))
reports.Write ('%d employers found\n' % (nempl))
if DevReports:
reports.DevBugReports (hlist, len(bugs))
reports.EmplBugReports (elist, len(bugs))