RobotKernal-UESTC/Code/MowingRobot/pibot_ros/third_party/libfreenect2/tools/mkcontrib.py

27 lines
1007 B
Python
Raw Normal View History

2023-12-14 23:56:56 +08:00
# 1. Visual inspection: python mkcontrib.py
# 2. If OK, python mkcontrib.py | grep -v ^# > CONTRIB
from subprocess import Popen, PIPE
from collections import defaultdict, Counter
p = Popen(["git","log","--no-merges","--format=%aN <%aE>"], stdout=PIPE).stdout
common_email = defaultdict(Counter)
common_name = defaultdict(Counter)
for line in p:
author, email = line.rstrip().split('<')
common_email[author].update([email])
common_name[email].update([author])
for email in common_name:
names = common_name[email]
names = sorted(names, key=lambda x: (names[x], len(x)), reverse=True)
for name in names[1:]:
common_email[names[0]] += common_email[name]
del common_email[name]
print '# Less common or shorter name', name, 'is replaced by', names[0]
for name in sorted(common_email):
for k in common_email[name].most_common()[1:]:
print '# Less common email <' + k[0] + ' is removed.'
print name + '<' + common_email[name].most_common(1)[0][0]