Skip to content

Instantly share code, notes, and snippets.

@siddhesh
Last active August 10, 2021 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddhesh/15ea1f5e435ace9774f485030695ee02 to your computer and use it in GitHub Desktop.
Save siddhesh/15ea1f5e435ace9774f485030695ee02 to your computer and use it in GitHub Desktop.
Clean up raw CONTRIBUTED-BY output into something nicer looking
# The raw CONTRIBUTED-BY file was generated by editing all files to remove the
# Contributed by lines and then running the following command:
#
# git diff -U1 | grep "^-" | sed -e 's/--- a\/\(.*\)/\1:/' -e 's/^-\(.*\)/\1\n/' >> CONTRIBUTED-BY
credit = {}
with open('CONTRIBUTED-BY', 'r') as contrfile:
curkey = ''
credit[''] = ''
for l in contrfile.readlines():
if l[len(l) - 2] == ':':
curkey = l
credit[curkey] = ''
else:
l = l.strip('*%/ \t\n!#')
if l:
credit[curkey] = credit[curkey] + '\n ' + l
print(credit[''])
credit[''] = ''
for k in sorted(credit.keys()):
print(k.strip())
print(" %s\n" % credit[k].strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment