improve(pipreqs): Remove unnecessary if statements

This commit is contained in:
Vadim Kravcenko 2015-05-08 11:15:37 +02:00
parent 084a82c7b7
commit 50470f7836

View File

@ -84,8 +84,6 @@ def get_imports_info(imports):
except HTTPError: except HTTPError:
logging.debug('Package does not exist or network problems') logging.debug('Package does not exist or network problems')
continue continue
if not data or not data.release_ids:
continue
last_release = data.latest_release_id last_release = data.latest_release_id
result.append({'name': item, 'version': last_release}) result.append({'name': item, 'version': last_release})
return result return result
@ -100,19 +98,12 @@ def get_locally_installed_packages():
with open(os.path.join(root, item), "r") as f: with open(os.path.join(root, item), "r") as f:
package = root.split("/")[-1].split("-") package = root.split("/")[-1].split("-")
package_import = f.read().strip().split("\n") package_import = f.read().strip().split("\n")
package_import_name = ""
for item in package_import: for item in package_import:
if item not in ["tests", "_tests"]: if item not in ["tests", "_tests"]:
package_import_name = item packages[item] = {
break 'version': package[1].replace(".dist", ""),
if package_import_name == "": 'name': package[0]
logging.debug( }
'Could not determine import name for package ' + str(package_import))
else:
packages[package_import_name] = {
'version': package[1].replace(".dist", ""),
'name': package[0]
}
return packages return packages