Tools: generate_manifest.py: make flake8 clean

This commit is contained in:
Peter Barker 2022-09-07 13:51:10 +10:00 committed by Peter Barker
parent 4008df1314
commit 3f5cde4bb1

View File

@ -1,6 +1,9 @@
#!/usr/bin/env python
import copy
'''
AP_FLAKE8_CLEAN
'''
import fnmatch
import gen_stable
import gzip
@ -111,6 +114,7 @@ brand_map = {
"GEPRC_TAKER_H743": ("TAKER H743 BT", "GEPRC"),
}
class Firmware():
def __init__(self,
date=None,
@ -198,7 +202,7 @@ class ManifestGenerator():
'''parses get-version.txt (as emitted by build_binaries.py, returns
git sha from it'''
content = open(filepath).read()
sha_regex = re.compile("APMVERSION: \S+\s+(\S+)")
sha_regex = re.compile(r"APMVERSION: \S+\s+(\S+)")
m = sha_regex.search(content)
if m is None:
raise Exception(
@ -349,7 +353,7 @@ class ManifestGenerator():
vehicletype,
releasetype="dev"):
'''accumulate additional information about firmwares from directory'''
variant_firmware_regex = re.compile("[^-]+-(?P<variant>v\d+)[.px4]")
variant_firmware_regex = re.compile(r"[^-]+-(?P<variant>v\d+)[.px4]")
if not os.path.isdir(dir):
return
try:
@ -393,7 +397,7 @@ class ManifestGenerator():
except ValueError:
print("malformed firmware-version.txt at (%s)" % (firmware_version_file,), file=sys.stderr)
continue
except Exception as ex:
except Exception:
print("bad file %s" % firmware_version_file, file=sys.stderr)
# this exception is swallowed.... the current archive
# is incomplete.
@ -488,7 +492,7 @@ class ManifestGenerator():
def walk_directory(self, basedir):
'''walks directory structure created by build_binaries, returns Python
structure representing releases in that structure'''
year_month_regex = re.compile("(?P<year>\d{4})-(?P<month>\d{2})")
year_month_regex = re.compile(r"(?P<year>\d{4})-(?P<month>\d{2})")
firmwares = []
@ -568,7 +572,6 @@ class ManifestGenerator():
self.add_USB_IDs(some_json)
#print(some_json['url'])
firmware_json.append(some_json)
# now the features the firmware supports...
@ -649,6 +652,7 @@ class ManifestGenerator():
'''write generated features JSON content to path'''
self.write_json(self.json_features(), path)
def usage():
return '''Usage:
generate-manifest.py basedir'''