Skip to content

Instantly share code, notes, and snippets.

@cpelley
Created September 23, 2013 08:00
Show Gist options
  • Save cpelley/6667660 to your computer and use it in GitHub Desktop.
Save cpelley/6667660 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import re
def main(fnme):
with open(fnme, 'r') as fh:
lines = fh.readlines()
parsed = []
for ind, line in enumerate(lines):
pattern = '^[\s]*def\s|'
if re.match(r'{0}def|{0}class'.format(pattern), line):
print_line = line.replace('\n', '')
print_line = print_line.replace(':', '')
print_line = "{}:{}:'{}'".format(fnme, ind+1, print_line)
parsed.append(print_line)
print print_line
if __name__ == '__main__':
if len(sys.argv) is 2:
fnme = sys.argv[1]
else:
sys.exit[0]
main(fnme)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment