8
8
"""
9
9
10
10
from __future__ import print_function
11
+
11
12
from subprocess import check_output
12
13
13
14
# --- output settings
29
30
'Stefan Seefeld <[email protected] >' :
30
31
[
'Stefan Seefeld <[email protected] >' ],
31
32
'John Rouillard <[email protected] >' :
32
- ['rouilj@uland' , 'rouilj' ]
33
-
33
+ ['rouilj@uland' , 'rouilj' ],
34
34
}
35
35
ROBOTS = [
'No Author <[email protected] >' ]
36
- # /--
36
+ # /--
37
37
38
38
39
39
def compress (years ):
@@ -85,8 +85,12 @@ def compress(years):
85
85
if verbose :
86
86
print ("Getting HG log..." )
87
87
print ("Using: " , command )
88
-
88
+
89
89
authorship = check_output (command , shell = True )
90
+
91
+ if not isinstance (authorship , str ):
92
+ authorship = authorship .decode ('utf-8' )
93
+
90
94
# authorship are strings like
91
95
# 2003,Richard Jones <[email protected] >
92
96
# ...
@@ -111,11 +115,11 @@ def compress(years):
111
115
author = author .replace ('<' , '(' )
112
116
author = author .replace ('>' , ')' )
113
117
# years
114
- if not year in years :
118
+ if year not in years :
115
119
years [year ] = set ()
116
120
years [year ].add (author )
117
121
# names
118
- if not author in names :
122
+ if author not in names :
119
123
names [author ] = set ()
120
124
names [author ].add (int (year ))
121
125
@@ -134,14 +138,14 @@ def compress(years):
134
138
if verbose :
135
139
print ("Years for each contributor..." )
136
140
print ('' )
137
-
141
+
138
142
def last_year (name ):
139
143
"""Return year of the latest contribution for a given name"""
140
- return sorted (list ( names [name ]) )[- 1 ]
144
+ return sorted (names [name ])[- 1 ]
141
145
142
146
def first_year (name ):
143
147
"""Return year of the first contribution"""
144
- return sorted (list ( names [name ]) )[0 ]
148
+ return sorted (names [name ])[0 ]
145
149
146
150
def year_key (name ):
147
151
"""
@@ -150,9 +154,9 @@ def year_key(name):
150
154
the most recent and long-term contributors are at the top.
151
155
"""
152
156
return (last_year (name ), - first_year (name ))
153
-
157
+
154
158
print ("Copyright (c)" )
155
- for author in sorted (list ( names ) , key = year_key , reverse = True ):
159
+ for author in sorted (names , key = year_key , reverse = True ):
156
160
years = list (names [author ])
157
161
yearstr = compress (years )
158
162
0 commit comments