@@ -77,7 +77,7 @@ python do_fetch() {
if os.path.exists(db_file):
shutil.copy2(db_file, db_tmp_file)
- if update_db_file(db_tmp_file, d) == True:
+ if update_db_file(db_tmp_file, d):
# Update downloaded correctly, can swap files
shutil.move(db_tmp_file, db_file)
else:
@@ -136,9 +136,11 @@ def update_db_file(db_tmp_file, d):
"""
Update the given database file
"""
- import bb.utils, bb.progress
+ import bb.progress
+ import bb.utils
from datetime import date
- import urllib, gzip, sqlite3
+ import sqlite3
+ import urllib
YEAR_START = 2002
cve_socket_timeout = int(d.getVar("CVE_SOCKET_TIMEOUT"))
@@ -167,8 +169,8 @@ def update_db_file(db_tmp_file, d):
return False
if response:
- for l in response.read().decode("utf-8").splitlines():
- key, value = l.split(":", 1)
+ for line in response.read().decode("utf-8").splitlines():
+ key, value = line.split(":", 1)
if key == "lastModifiedDate":
last_modified = value
break
@@ -332,7 +334,7 @@ def get_metric_entry(metric):
secondaries = [c for c in metric if c['type'] == "Secondary"]
if len(primaries) > 0:
return primaries[0]
- elif len(secondaries)>0:
+ elif len(secondaries) > 0:
return secondaries[0]
return None
@@ -341,10 +343,10 @@ def update_db_fkie(conn, jsondata):
root = json.loads(jsondata)
for elt in root['cve_items']:
- if not 'vulnStatus' in elt or elt['vulnStatus'] == 'Rejected':
+ if 'vulnStatus' not in elt or elt['vulnStatus'] == 'Rejected':
continue
- if not 'configurations' in elt:
+ if 'configurations' not in elt:
continue
accessVector = None
Fixes following pycodestyle complaints: cve-update-db-native.bb:80:39: E712 comparison to True should be 'if cond is True:' or 'if cond:' cve-update-db-native.bb:128:20: E401 multiple imports on one line cve-update-db-native.bb:130:18: E401 multiple imports on one line cve-update-db-native.bb:171:21: E741 ambiguous variable name 'l' cve-update-db-native.bb:335:26: E225 missing whitespace around operator cve-update-db-native.bb:344:12: E713 test for membership should be 'not in' cve-update-db-native.bb:347:12: E713 test for membership should be 'not in' Also leaves out a redundant 'gzip' import in update_db_file(). Signed-off-by: Niko Mauno <niko.mauno@vaisala.com> --- meta/recipes-core/meta/cve-update-db-native.bb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)