Mercurial > kallithea
comparison scripts/update-copyrights.py @ 8368:e5ccabbc3cd7 stable
release: merge default to stable for 0.6.0
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Sat, 02 May 2020 21:20:43 +0200 |
parents | d6ccf6a9fd11 |
children |
comparison
equal
deleted
inserted
replaced
8320:b1b1f69b1f28 | 8368:e5ccabbc3cd7 |
---|---|
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 """ | 4 """ |
5 Kallithea script for maintaining contributor lists from version control | 5 Kallithea script for maintaining contributor lists from version control |
6 history. | 6 history. |
49 """Return key for sorting contributors "fairly": | 49 """Return key for sorting contributors "fairly": |
50 * latest contribution | 50 * latest contribution |
51 * first contribution | 51 * first contribution |
52 * number of contribution years | 52 * number of contribution years |
53 * name (with some unicode normalization) | 53 * name (with some unicode normalization) |
54 The entries must be 2-tuples of a list of string years and the unicode name""" | 54 The entries must be 2-tuples of a list of string years and the name""" |
55 return (x[0] and -int(x[0][-1]), | 55 years, name = x |
56 x[0] and int(x[0][0]), | 56 if not years: |
57 -len(x[0]), | 57 years = ['0'] |
58 x[1].decode('utf-8').lower().replace(u'\xe9', u'e').replace(u'\u0142', u'l') | 58 return (-int(years[-1]), # primarily sort by latest contribution |
59 int(years[0]), # then sort by first contribution | |
60 -len(years), # then sort by length of contribution (no gaps) | |
61 name.lower().replace('\xe9', 'e').replace('\u0142', 'l') # finally sort by name | |
59 ) | 62 ) |
60 | 63 |
61 | 64 |
62 def nice_years(l, dash='-', join=' '): | 65 def nice_years(l, dash='-', join=' '): |
63 """Convert a list of years into brief range like '1900-1901, 1921'.""" | 66 """Convert a list of years into brief range like '1900-1901, 1921'.""" |
132 insert_entries( | 135 insert_entries( |
133 filename='kallithea/templates/about.html', | 136 filename='kallithea/templates/about.html', |
134 all_entries=repo_entries + contributor_data.other_about + contributor_data.other, | 137 all_entries=repo_entries + contributor_data.other_about + contributor_data.other, |
135 no_entries=contributor_data.no_about, | 138 no_entries=contributor_data.no_about, |
136 domain_extra=contributor_data.domain_extra, | 139 domain_extra=contributor_data.domain_extra, |
137 split_re=r'(?: <li>Copyright © [^\n]*</li>\n)*', | 140 split_re=r'(?: <li>Copyright © [^\n]+</li>\n)+', |
138 normalize_name=lambda name: name.split('<', 1)[0].strip(), | 141 normalize_name=lambda name: name.split('<', 1)[0].strip(), |
139 format_f=lambda years, name: ' <li>Copyright © %s, %s</li>\n' % (nice_years(years, '–', ', '), name), | 142 format_f=lambda years, name: ' <li>Copyright © %s, %s</li>\n' % (nice_years(years, '–', ', '), name), |
140 ) | 143 ) |
141 | 144 |
142 insert_entries( | 145 insert_entries( |
143 filename='CONTRIBUTORS', | 146 filename='CONTRIBUTORS', |
144 all_entries=repo_entries + contributor_data.other_contributors + contributor_data.other, | 147 all_entries=repo_entries + contributor_data.other_contributors + contributor_data.other, |
145 no_entries=contributor_data.total_ignore, | 148 no_entries=contributor_data.total_ignore, |
146 domain_extra=contributor_data.domain_extra, | 149 domain_extra=contributor_data.domain_extra, |
147 split_re=r'(?: [^\n]*\n)*', | 150 split_re=r'(?: [^\n]+\n)+', |
148 normalize_name=lambda name: name, | 151 normalize_name=lambda name: name, |
149 format_f=lambda years, name: (' %s%s%s\n' % (name, ' ' if years else '', nice_years(years))), | 152 format_f=lambda years, name: (' %s%s%s\n' % (name, ' ' if years else '', nice_years(years))), |
150 ) | 153 ) |
151 | 154 |
152 insert_entries( | 155 insert_entries( |
153 filename='kallithea/templates/base/base.html', | 156 filename='kallithea/templates/base/base.html', |
154 all_entries=repo_entries, | 157 all_entries=repo_entries, |
155 no_entries=contributor_data.total_ignore, | 158 no_entries=contributor_data.total_ignore, |
156 domain_extra={}, | 159 domain_extra={}, |
157 split_re=r'(?<=©) .* (?=by various authors)', | 160 split_re=r'(?<=©) .+ (?=by various authors)', |
158 normalize_name=lambda name: '', | 161 normalize_name=lambda name: '', |
159 format_f=lambda years, name: ' ' + nice_years(years, '–', ', ') + ' ', | 162 format_f=lambda years, name: ' ' + nice_years(years, '–', ', ') + ' ', |
160 ) | 163 ) |
161 | 164 |
162 #docs/conf.py:copyright = u'2010-2016 by various authors, licensed as GPLv3.' | 165 #docs/conf.py:copyright = u'2010-2016 by various authors, licensed as GPLv3.' |
163 insert_entries( | 166 insert_entries( |
164 filename='docs/conf.py', | 167 filename='docs/conf.py', |
165 all_entries=repo_entries, | 168 all_entries=repo_entries, |
166 no_entries=contributor_data.total_ignore, | 169 no_entries=contributor_data.total_ignore, |
167 domain_extra={}, | 170 domain_extra={}, |
168 split_re=r"(?<=copyright = u').*(?= by various authors)", | 171 split_re=r"(?<=copyright = ').+(?= by various authors)", |
169 normalize_name=lambda name: '', | 172 normalize_name=lambda name: '', |
170 format_f=lambda years, name: nice_years(years, '-', ', '), | 173 format_f=lambda years, name: nice_years(years, '-', ', '), |
171 ) | 174 ) |
172 | 175 |
173 | 176 |