File tree Expand file tree Collapse file tree 1 file changed +35
-2
lines changed
Expand file tree Collapse file tree 1 file changed +35
-2
lines changed Original file line number Diff line number Diff line change 5353 print (" " + author )
5454 print ('' )
5555
56+
57+ def compress_years (years ):
58+ """
59+ Given a list of years like [2003, 2004, 2007],
60+ compress it into string like '2003-2004, 2007'
61+ """
62+ years = sorted (years )
63+ # compress years into string
64+ comma = ', '
65+ yearstr = ''
66+ for i in range (0 ,len (years )- 1 ):
67+ if years [i + 1 ]- years [i ] == 1 :
68+ if not yearstr or yearstr .endswith (comma ):
69+ yearstr += '%s' % years [i ]
70+ if yearstr .endswith ('-' ):
71+ pass
72+ else :
73+ yearstr += '-'
74+ else :
75+ yearstr += '%s, ' % years [i ]
76+
77+ if len (years ) == 1 :
78+ yearstr += str (years [0 ])
79+ else :
80+ yearstr += '%s' % years [- 1 ]
81+ return yearstr
82+
83+
5684if years_for_contributors :
5785 if verbose :
5886 print ("Years for each contributor..." )
5987 print ('' )
6088 for author in sorted (names ):
61- years = sorted (names [author ])
62- print (years , author )
89+ years = list (names [author ])
90+ yearstr = compress_years (years )
91+
92+ if 1 : #DEBUG
93+ print (years , yearstr , author )
94+ else :
95+ print (yearstr , author )
6396 print ('' )
You can’t perform that action at this time.
0 commit comments