File: get_author_list_from_gitlog.py

package info (click to toggle)
imx-usb-loader 0~git20200517.30b43d69-2
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,348 kB
  • sloc: ansic: 4,214; xml: 417; makefile: 85; python: 29
file content (51 lines) | stat: -rwxr-xr-x 1,934 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
#
# Copyright (C) 2017 Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
# USA


import re
import sys

authorR = re.compile(r'^Author:\s+(.*)')
dateR = re.compile(r'^Date:\s+(\w+)\s+(\w+)\s+(\w+)\s+(\d+[:]\d+[:]\d+)\s+(\d+)(\s+)?(.*)')

if __name__ == '__main__':
    rec1 = {}
    currentAuthor = None
    for line in sys.stdin:
        line = line.rstrip()
        authorM = authorR.match(line)
        if (authorM):
            currentAuthor = authorM.group(1)
            continue
        dateM = dateR.match(line)
        if (dateM):
            year = int(dateM.group(5))
            if (currentAuthor):
                if (currentAuthor in rec1):
                    if (year < rec1[currentAuthor]['min']):
                        rec1[currentAuthor]['min'] = year
                    if (year > rec1[currentAuthor]['max']):
                        rec1[currentAuthor]['max'] = year
                else:
                    rec1[currentAuthor] = { 'min':year, 'max':year }
    for k in sorted(rec1.keys()):
        if (rec1[k]['min'] == rec1[k]['max']):
            print ('%d %s'%(rec1[k]['max'], k))
        else:
            print ('%d-%d %s'%(rec1[k]['min'], rec1[k]['max'], k))