Skip to content

Instantly share code, notes, and snippets.

@grapemix
Created March 8, 2019 19:57
Show Gist options
  • Save grapemix/473a52e3c9e009ab7639d163e9c92dee to your computer and use it in GitHub Desktop.
Save grapemix/473a52e3c9e009ab7639d163e9c92dee to your computer and use it in GitHub Desktop.
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