mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
Merge pull request #24 from Lee-W/master
Skip irreverent directory and change logging level
This commit is contained in:
commit
d558f73c4e
10
.gitignore
vendored
10
.gitignore
vendored
@ -42,3 +42,13 @@ output/*/index.html
|
|||||||
# Sphinx
|
# Sphinx
|
||||||
docs/_build
|
docs/_build
|
||||||
.idea/
|
.idea/
|
||||||
|
# Created by https://www.gitignore.io/api/vim
|
||||||
|
|
||||||
|
### Vim ###
|
||||||
|
[._]*.s[a-w][a-z]
|
||||||
|
[._]s[a-w][a-z]
|
||||||
|
*.un~
|
||||||
|
Session.vim
|
||||||
|
.netrwhist
|
||||||
|
*~
|
||||||
|
|
||||||
|
@ -32,10 +32,18 @@ REGEXP = [
|
|||||||
def get_all_imports(path):
|
def get_all_imports(path):
|
||||||
imports = []
|
imports = []
|
||||||
candidates = []
|
candidates = []
|
||||||
|
ignore_dirs = [".git", "__pycache__", "env"]
|
||||||
|
|
||||||
for root, dirs, files in os.walk(path):
|
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))
|
candidates.append(os.path.basename(root))
|
||||||
files = [fn for fn in files if os.path.splitext(fn)[1] == ".py"]
|
files = [fn for fn in files if os.path.splitext(fn)[1] == ".py"]
|
||||||
|
|
||||||
candidates += [os.path.splitext(fn)[0] for fn in files]
|
candidates += [os.path.splitext(fn)[0] for fn in files]
|
||||||
for file_name in files:
|
for file_name in files:
|
||||||
with open(os.path.join(root, file_name), "r") as f:
|
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"))
|
os.path.join(args['<path>'], "requirements.txt"))
|
||||||
|
|
||||||
if not args["--savepath"] and not args["--force"] and os.path.exists(path):
|
if not args["--savepath"] and not args["--force"] and os.path.exists(path):
|
||||||
logging.info("Requirements.txt already exists, "
|
logging.warning("Requirements.txt already exists, "
|
||||||
"use --force to overwrite it")
|
"use --force to overwrite it")
|
||||||
return
|
return
|
||||||
generate_requirements_file(path, imports)
|
generate_requirements_file(path, imports)
|
||||||
logging.info("Successfully saved requirements file in " + path)
|
logging.info("Successfully saved requirements file in " + path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user