MCPcopy Create free account
hub / github.com/PyWavelets/pywt / main

Function main

util/authors.py:24–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22
23
24def main():
25 p = optparse.OptionParser(__doc__.strip())
26 p.add_option("-d", "--debug", action="store_true",
27 help="print debug output")
28 p.add_option("-n", "--new", action="store_true",
29 help="print debug output")
30 options, args = p.parse_args()
31
32 if len(args) != 1:
33 p.error("invalid number of arguments")
34
35 try:
36 rev1, rev2 = args[0].split('..')
37 except ValueError:
38 p.error("argument is not a revision range")
39
40 NAME_MAP = load_name_map(MAILMAP_FILE)
41
42 # Analyze log data
43 all_authors = set()
44 authors = set()
45
46 def analyze_line(line, names, disp=False):
47 line = line.strip().decode('utf-8')
48
49 # Check the commit author name
50 m = re.match('^@@@([^@]*)@@@', line)
51 if m:
52 name = m.group(1)
53 line = line[m.end():]
54 name = NAME_MAP.get(name, name)
55 if disp:
56 if name not in names:
57 stdout_b.write(f" - Author: {name}\n".encode())
58 names.add(name)
59
60 # Look for "thanks to" messages in the commit log
61 m = re.search(r'([Tt]hanks to|[Cc]ourtesy of) ([A-Z][A-Za-z]*? [A-Z][A-Za-z]*? [A-Z][A-Za-z]*|[A-Z][A-Za-z]*? [A-Z]\. [A-Z][A-Za-z]*|[A-Z][A-Za-z ]*? [A-Z][A-Za-z]*|[a-z0-9]+)($|\.| )', line)
62 if m:
63 name = m.group(2)
64 if name not in ('this',):
65 if disp:
66 stdout_b.write(f" - Log : {line.strip().encode('utf-8')}\n")
67 name = NAME_MAP.get(name, name)
68 names.add(name)
69
70 line = line[m.end():].strip()
71 line = re.sub(r'^(and|, and|, ) ', 'Thanks to ', line)
72 analyze_line(line.encode('utf-8'), names)
73
74 # Find all authors before the named range
75 for line in git.pipe('log', '--pretty=@@@%an@@@%n@@@%cn@@@%n%b',
76 f'{rev1}'):
77 analyze_line(line, all_authors)
78
79 # Find authors in the named range
80 for line in git.pipe('log', '--pretty=@@@%an@@@%n@@@%cn@@@%n%b',
81 f'{rev1}..{rev2}'):

Callers 1

authors.pyFile · 0.70

Calls 3

load_name_mapFunction · 0.85
analyze_lineFunction · 0.85
pipeMethod · 0.80

Tested by

no test coverage detected