mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
Merge 5633827177751193f51f2c4563a7ab14b36efcd8 into 5707a39df693ddd243ddd7c47ff35ce66d25a6c6
This commit is contained in:
commit
4ba9c079b4
@ -349,7 +349,10 @@ def compare_modules(file_, imports):
|
||||
|
||||
imports = [imports[i]["name"] for i in range(len(imports))]
|
||||
modules = [modules[i]["name"] for i in range(len(modules))]
|
||||
modules_not_imported = set(modules) - set(imports)
|
||||
# modules => declared in requirements
|
||||
# imports => all modules needed
|
||||
# not imported => all modules - declared
|
||||
modules_not_imported = set(imports) - set(modules)
|
||||
|
||||
return modules_not_imported
|
||||
|
||||
@ -359,7 +362,7 @@ def diff(file_, imports):
|
||||
modules_not_imported = compare_modules(file_, imports)
|
||||
|
||||
logging.info(
|
||||
"The following modules are in {} but do not seem to be imported: "
|
||||
"The following modules are in {} but do not seem to be imported: \n"
|
||||
"{}".format(file_, ", ".join(x for x in modules_not_imported)))
|
||||
|
||||
|
||||
@ -432,8 +435,12 @@ def init(args):
|
||||
os.path.join(input_path, "requirements.txt"))
|
||||
|
||||
if args["--diff"]:
|
||||
diff(args["--diff"], imports)
|
||||
return
|
||||
if os.path.exists(args["--diff"]):
|
||||
diff(args["--diff"], imports)
|
||||
return
|
||||
else:
|
||||
logging.info("The file [ %s ] not exist" % args["--diff"])
|
||||
return
|
||||
|
||||
if args["--clean"]:
|
||||
clean(args["--clean"], imports)
|
||||
|
Loading…
x
Reference in New Issue
Block a user