Skip to content

Instantly share code, notes, and snippets.

@JakeWharton
Created August 15, 2012 19:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JakeWharton/3362848 to your computer and use it in GitHub Desktop.
Save JakeWharton/3362848 to your computer and use it in GitHub Desktop.
Purge all @author tags!
#!/usr/bin/env python
import os
import re
os.system('git reset --hard HEAD')
os.system('git clean -fdx')
REs = [
r'''\s+\*\n\s+\* @author[^\n]*''',
r'''\s+-\s*\n\s+- @author[^\n]*''',
r'''\s+- @author[^\n]*''',
r'''\s+\* @author[^\n]*''',
r'''\n/\*\* @author[^\n]*\*/''',
]
def authors():
(stdin, stdout, stderr) = os.popen3('\grep -lrs "@author"')
return stdout.read().split()
for RE in REs:
for f in authors():
with open(f) as infile:
incontent = infile.read()
outcontent = re.sub(RE, '', incontent, re.M)
if (incontent != outcontent):
with open(f, 'w') as outfile:
outfile.write(outcontent)
remain = authors()
print(str(len(remain)) + " holdouts...")
if len(remain) > 0:
print("Next victim: " + remain[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment