88"""
99
1010from __future__ import print_function
11+
1112from subprocess import check_output
1213
1314# --- output settings
2930 'Stefan Seefeld <[email protected] >' :
3031 [
'Stefan Seefeld <[email protected] >' ],
3132 'John Rouillard <[email protected] >' :
32- ['rouilj@uland' , 'rouilj' ]
33-
33+ ['rouilj@uland' , 'rouilj' ],
3434}
3535ROBOTS = [
'No Author <[email protected] >' ]
36- # /--
36+ # /--
3737
3838
3939def compress (years ):
@@ -85,8 +85,12 @@ def compress(years):
8585 if verbose :
8686 print ("Getting HG log..." )
8787 print ("Using: " , command )
88-
88+
8989 authorship = check_output (command , shell = True )
90+
91+ if not isinstance (authorship , str ):
92+ authorship = authorship .decode ('utf-8' )
93+
9094 # authorship are strings like
9195 # 2003,Richard Jones <[email protected] > 9296 # ...
@@ -111,11 +115,11 @@ def compress(years):
111115 author = author .replace ('<' , '(' )
112116 author = author .replace ('>' , ')' )
113117 # years
114- if not year in years :
118+ if year not in years :
115119 years [year ] = set ()
116120 years [year ].add (author )
117121 # names
118- if not author in names :
122+ if author not in names :
119123 names [author ] = set ()
120124 names [author ].add (int (year ))
121125
@@ -134,14 +138,14 @@ def compress(years):
134138 if verbose :
135139 print ("Years for each contributor..." )
136140 print ('' )
137-
141+
138142 def last_year (name ):
139143 """Return year of the latest contribution for a given name"""
140- return sorted (list ( names [name ]) )[- 1 ]
144+ return sorted (names [name ])[- 1 ]
141145
142146 def first_year (name ):
143147 """Return year of the first contribution"""
144- return sorted (list ( names [name ]) )[0 ]
148+ return sorted (names [name ])[0 ]
145149
146150 def year_key (name ):
147151 """
@@ -150,9 +154,9 @@ def year_key(name):
150154 the most recent and long-term contributors are at the top.
151155 """
152156 return (last_year (name ), - first_year (name ))
153-
157+
154158 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 ):
156160 years = list (names [author ])
157161 yearstr = compress (years )
158162
0 commit comments