Created
September 25, 2018 15:49
-
-
Save ndevenish/e542f746795d0c04d8d607fe125b9887 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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