Skip to content

Instantly share code, notes, and snippets.

@ndevenish
Created September 25, 2018 15:49
Show Gist options
  • Save ndevenish/e542f746795d0c04d8d607fe125b9887 to your computer and use it in GitHub Desktop.
Save ndevenish/e542f746795d0c04d8d607fe125b9887 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
from collections import Counter
all_files = []
for path, dirs, files in os.walk("."):
all_files.extend(os.path.join(path, x) for x in files if x.endswith(".py"))
exclusions = { "", "{", "}", "'''", '"""',"},",
"else:",
}
maxl = max(len(x) for x in all_files)
for fname in all_files:
with open(fname) as f:
lines = [x.strip() for x in f.readlines()]
lines = [x for x in lines if not x in exclusions]
c = Counter(lines)
for key, n in c.items():
if n == 1:
continue
print("{:3d}".format(n), fname.ljust(maxl), key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment