...
 
Commits (3)
......@@ -32,7 +32,7 @@ def parse_rule(f) -> Iterable[Rule]:
'ATTRS\{idVendor\}=="(?P<vendors>[^"]*)", '
'ATTRS\{idProduct\}=="(?P<products>[^"]*)"')
for line in f.readlines():
for line_no, line in enumerate(f.readlines(), start=1):
line = line.strip()
# Skip irrelevant lines
......@@ -41,19 +41,20 @@ def parse_rule(f) -> Iterable[Rule]:
parse = syntax.match(line)
if parse is None:
raise ValueError(f"Invalid syntax on line XXXTODO: '{line}'")
raise ValueError(f"Invalid syntax on line {line_no}: '{line}'")
yield Rule(parse.group('vendors').split('|'),
parse.group('products').split('|'))
if __name__ == '__main__':
with open('debian/libu2f-udev.metainfo.xml', 'rb') as f:
data = xml.etree.ElementTree.parse(f)
with open('debian/libu2f-udev.metainfo.xml', 'rb') as metainfo:
data = xml.etree.ElementTree.parse(metainfo)
provides = data.getroot().find('provides')
assert provides is not None
with open('70-u2f.rules') as f:
for rule in parse_rule(f):
with open('70-u2f.rules') as rules_file:
for rule in parse_rule(rules_file):
for device in rule.devices():
modalias = xml.etree.ElementTree.Element('modalias')
modalias.text = device.modalias()
......
......@@ -7,7 +7,9 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
lint_scripts:
shellcheck debian/*.postinst
flake8 debian/*.py
mypy debian/*.py
override_dh_auto_configure:
dh_auto_configure -- \
......