Merge 5633827177751193f51f2c4563a7ab14b36efcd8 into 5707a39df693ddd243ddd7c47ff35ce66d25a6c6

This commit is contained in:
spenly 2018-03-13 10:22:22 +00:00 committed by GitHub
commit 4ba9c079b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)