瀏覽代碼

add comdline option for name translation`

Dan Rapp 7 年之前
父節點
當前提交
3036127331
共有 1 個文件被更改,包括 9 次插入6 次删除
  1. 9
    6
      gitstats/gitstats.py

+ 9
- 6
gitstats/gitstats.py 查看文件

@@ -9,6 +9,8 @@ import time
9 9
 
10 10
 import multiprocessing_logging
11 11
 
12
+from collections import defaultdict
13
+
12 14
 from .gitdatacollector import GitDataCollector
13 15
 from .htmlreportcreator import HTMLReportCreator
14 16
 from .miscfuncs import getgnuplotversion
@@ -29,11 +31,7 @@ conf = {
29 31
     'processes': 8,
30 32
     'start_date': '',
31 33
     'logging': logging.INFO,
32
-    'name_xlate': {
33
-        'lmonson': 'Lynn Monson',
34
-        'DallanQ': 'Dallan Quass',
35
-        'Daniel Rapp': 'Dan Rapp'
36
-    }
34
+    'name_xlate': defaultdict(dict)
37 35
 }
38 36
 
39 37
 class GitStats:
@@ -43,6 +41,7 @@ class GitStats:
43 41
 
44 42
     Options:
45 43
     -c key=value     Override configuration value
44
+    -n key=value     Define author name equivalency (key will treated the same as value)
46 45
 
47 46
     Default config values:
48 47
     {conf}
@@ -51,7 +50,7 @@ class GitStats:
51 50
     """)
52 51
 
53 52
     def run(self):
54
-        optlist, args = getopt.getopt(sys.argv[1:], 'hc:', ["help"])
53
+        optlist, args = getopt.getopt(sys.argv[1:], 'hc:n:', ["help"])
55 54
         for o, v in optlist:
56 55
             if o == '-c':
57 56
                 key, value = v.split('=', 1)
@@ -64,6 +63,10 @@ class GitStats:
64 63
             elif o in ('-h', '--help'):
65 64
                 self._usage()
66 65
                 sys.exit()
66
+            elif o == '-n':
67
+                key, value = v.split('=', 1)
68
+                conf['name_xlate'][key] = value
69
+
67 70
 
68 71
         if len(args) < 2:
69 72
             self._usage()