Created
March 8, 2019 19:57
-
-
Save grapemix/473a52e3c9e009ab7639d163e9c92dee to your computer and use it in GitHub Desktop.
This file contains 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
from __future__ import print_function | |
import re | |
import os | |
import sys | |
if __name__ == "__main__": | |
try: | |
root_path = sys.argv[1] | |
except: | |
root_path = "." | |
empty_regex = re.compile(r"^\s*$") | |
for root, dirs, files in os.walk(root_path, topdown=False): | |
for name in files: | |
with open(os.path.join(root, name), "r") as fd: | |
is_empty = True | |
try: | |
content = fd.read() | |
except: | |
#raise | |
continue | |
for i, ln in enumerate(content.split("\n")): | |
if empty_regex.match(ln) is None and ln[:2] not in [ | |
"# ", | |
"/*", | |
"*/", | |
"* ", | |
"#" | |
]: | |
is_empty = False | |
break | |
if is_empty and i > 0: | |
print(os.path.join(root, name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment