mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 19:45:22 +00:00
Merge pull request #344 from clvnkhr/Check-if-requirements.txt-exist-before-proceeding-further-inspection-#285
resolve issue #285
This commit is contained in:
commit
e5493d922e
@ -412,6 +412,16 @@ def init(args):
|
|||||||
if extra_ignore_dirs:
|
if extra_ignore_dirs:
|
||||||
extra_ignore_dirs = extra_ignore_dirs.split(',')
|
extra_ignore_dirs = extra_ignore_dirs.split(',')
|
||||||
|
|
||||||
|
path = (args["--savepath"] if args["--savepath"] else
|
||||||
|
os.path.join(input_path, "requirements.txt"))
|
||||||
|
if (not args["--print"]
|
||||||
|
and not args["--savepath"]
|
||||||
|
and not args["--force"]
|
||||||
|
and os.path.exists(path)):
|
||||||
|
logging.warning("requirements.txt already exists, "
|
||||||
|
"use --force to overwrite it")
|
||||||
|
return
|
||||||
|
|
||||||
candidates = get_all_imports(input_path,
|
candidates = get_all_imports(input_path,
|
||||||
encoding=encoding,
|
encoding=encoding,
|
||||||
extra_ignore_dirs=extra_ignore_dirs,
|
extra_ignore_dirs=extra_ignore_dirs,
|
||||||
@ -442,9 +452,6 @@ def init(args):
|
|||||||
# sort imports based on lowercase name of package, similar to `pip freeze`.
|
# sort imports based on lowercase name of package, similar to `pip freeze`.
|
||||||
imports = sorted(imports, key=lambda x: x['name'].lower())
|
imports = sorted(imports, key=lambda x: x['name'].lower())
|
||||||
|
|
||||||
path = (args["--savepath"] if args["--savepath"] else
|
|
||||||
os.path.join(input_path, "requirements.txt"))
|
|
||||||
|
|
||||||
if args["--diff"]:
|
if args["--diff"]:
|
||||||
diff(args["--diff"], imports)
|
diff(args["--diff"], imports)
|
||||||
return
|
return
|
||||||
@ -453,14 +460,6 @@ def init(args):
|
|||||||
clean(args["--clean"], imports)
|
clean(args["--clean"], imports)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (not args["--print"]
|
|
||||||
and not args["--savepath"]
|
|
||||||
and not args["--force"]
|
|
||||||
and os.path.exists(path)):
|
|
||||||
logging.warning("requirements.txt already exists, "
|
|
||||||
"use --force to overwrite it")
|
|
||||||
return
|
|
||||||
|
|
||||||
if args["--mode"]:
|
if args["--mode"]:
|
||||||
scheme = args.get("--mode")
|
scheme = args.get("--mode")
|
||||||
if scheme in ["compat", "gt", "no-pin"]:
|
if scheme in ["compat", "gt", "no-pin"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user