Merge pull request #24 from Lee-W/master

Skip irreverent directory and change logging level
This commit is contained in:
Vadim Kravcenko 2015-09-01 10:39:33 +02:00
commit d558f73c4e
2 changed files with 20 additions and 2 deletions

10
.gitignore vendored
View File

@ -42,3 +42,13 @@ output/*/index.html
# Sphinx
docs/_build
.idea/
# Created by https://www.gitignore.io/api/vim
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~

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:
@ -166,8 +174,8 @@ def init(args):
os.path.join(args['<path>'], "requirements.txt"))
if not args["--savepath"] and not args["--force"] and os.path.exists(path):
logging.info("Requirements.txt already exists, "
"use --force to overwrite it")
logging.warning("Requirements.txt already exists, "
"use --force to overwrite it")
return
generate_requirements_file(path, imports)
logging.info("Successfully saved requirements file in " + path)