Tools: flake8 fixes for generate_manifest.py

This commit is contained in:
Andrew Tridgell 2019-04-29 18:16:12 +10:00
parent 9da18cd6bc
commit 0abec1e0f3

View File

@ -92,7 +92,6 @@ class ManifestGenerator():
"filepath (%s) does not contain a git sha" % (filepath,)) "filepath (%s) does not contain a git sha" % (filepath,))
return m.group("sha") return m.group("sha")
def add_USB_IDs_PX4(self, firmware): def add_USB_IDs_PX4(self, firmware):
'''add USB IDs to a .px4 firmware''' '''add USB IDs to a .px4 firmware'''
url = firmware['url'] url = firmware['url']
@ -122,10 +121,10 @@ class ManifestGenerator():
print("bad apj path %s" % apj_path, file=sys.stderr) print("bad apj path %s" % apj_path, file=sys.stderr)
return return
apj_json = json.load(open(apj_path, 'r')) apj_json = json.load(open(apj_path, 'r'))
if not 'board_id' in apj_json: if 'board_id' not in apj_json:
print("no board_id in %s" % apj_path, file=sys.stderr) print("no board_id in %s" % apj_path, file=sys.stderr)
return return
if not 'platform' in firmware: if 'platform' not in firmware:
print("no platform for %s" % apj_path, file=sys.stderr) print("no platform for %s" % apj_path, file=sys.stderr)
return return
board_id = apj_json['board_id'] board_id = apj_json['board_id']
@ -182,8 +181,6 @@ class ManifestGenerator():
firmware['bootloader_str'].append('MindPX BL FMU v2.x') firmware['bootloader_str'].append('MindPX BL FMU v2.x')
firmware['USBID'].append('0x26AC/0x0030') firmware['USBID'].append('0x26AC/0x0030')
def add_USB_IDs(self, firmware): def add_USB_IDs(self, firmware):
'''add USB IDs to a firmware''' '''add USB IDs to a firmware'''
fmt = firmware['format'] fmt = firmware['format']
@ -194,8 +191,6 @@ class ManifestGenerator():
self.add_USB_IDs_ChibiOS(firmware) self.add_USB_IDs_ChibiOS(firmware)
return return
def add_firmware_data_from_dir(self, def add_firmware_data_from_dir(self,
dir, dir,
firmware_data, firmware_data,
@ -217,7 +212,7 @@ class ManifestGenerator():
try: try:
git_sha = self.git_sha_from_git_version( git_sha = self.git_sha_from_git_version(
os.path.join(some_dir, "git-version.txt")) os.path.join(some_dir, "git-version.txt"))
except Exception as e: except Exception:
continue continue
firmware_version_file = os.path.join(some_dir, firmware_version_file = os.path.join(some_dir,
"firmware-version.txt") "firmware-version.txt")
@ -225,11 +220,11 @@ class ManifestGenerator():
firmware_version = open(firmware_version_file).read() firmware_version = open(firmware_version_file).read()
firmware_version = firmware_version.strip() firmware_version = firmware_version.strip()
(version_numbers, release_type) = firmware_version.split("-") (version_numbers, release_type) = firmware_version.split("-")
except ValueError as e: except ValueError:
# print("malformed firmware-version.txt at (%s)" % # print("malformed firmware-version.txt at (%s)" %
# (firmware_version_file,), file=sys.stderr) # (firmware_version_file,), file=sys.stderr)
firmware_version = None firmware_version = None
except Exception as e: except Exception:
# this exception is swallowed.... the current archive # this exception is swallowed.... the current archive
# is incomplete. # is incomplete.
firmware_version = None firmware_version = None
@ -324,7 +319,7 @@ class ManifestGenerator():
else: else:
return [xfirmwares] return [xfirmwares]
def check_release_type(self, tag): def valid_release_type(self, tag):
'''check for valid release type''' '''check for valid release type'''
for r in RELEASE_TYPES: for r in RELEASE_TYPES:
if fnmatch.fnmatch(tag, r): if fnmatch.fnmatch(tag, r):
@ -370,7 +365,6 @@ class ManifestGenerator():
if fulldate in ["files.html", ".makehtml"]: if fulldate in ["files.html", ".makehtml"]:
# generated file which should be ignored # generated file which should be ignored
continue continue
print(fulldate, file=sys.stderr)
self.add_firmware_data_from_dir( self.add_firmware_data_from_dir(
os.path.join(year_month_path, fulldate), os.path.join(year_month_path, fulldate),
xfirmwares, xfirmwares,
@ -380,7 +374,7 @@ class ManifestGenerator():
# "beta", or the "latest" directory (treated as a # "beta", or the "latest" directory (treated as a
# release and handled specially later) # release and handled specially later)
tag = firstlevel tag = firstlevel
if not self.check_release_type(tag): if not self.valid_release_type(tag):
print("Unknown tag (%s) in directory (%s)" % print("Unknown tag (%s) in directory (%s)" %
(tag, os.path.join(vdir)), file=sys.stderr) (tag, os.path.join(vdir)), file=sys.stderr)
continue continue