Ignore irreverent directory when generating requirement.txt

* Currently ignore .git, __pycache__, env
This commit is contained in:
LeeW 2015-08-31 21:25:17 +08:00
parent fef28cc9c9
commit 301ff8ce83

View File

@ -32,10 +32,18 @@ REGEXP = [
def get_all_imports(path):
imports = []
candidates = []
ignore_dirs = [".git", "__pycache__", "env"]
for root, dirs, files in os.walk(path):
dirs[:] = [d for d in dirs if d not in ignore_dirs]
# for d in ignore_dirs:
# if d in dirs:
# dirs.remove(d)
candidates.append(os.path.basename(root))
files = [fn for fn in files if os.path.splitext(fn)[1] == ".py"]
candidates += [os.path.splitext(fn)[0] for fn in files]
for file_name in files:
with open(os.path.join(root, file_name), "r") as f: