summaryrefslogtreecommitdiff
path: root/tools/py3_driver_progress.py
diff options
context:
space:
mode:
authorChristoph Berg <christoph.berg@credativ.de>2022-11-08 11:40:45 +0100
committerChristoph Berg <christoph.berg@credativ.de>2022-11-08 11:40:45 +0100
commit42b1373eff59af2aebb218ded3d2d55cc96dc630 (patch)
treed6e7e435fa41c65fff7a73dd7dc99bb4a12da5c8 /tools/py3_driver_progress.py
parent176c8e29d64892072697c5d30513204773545a9b (diff)
parent6f19923a918f7fb63a444b0c99950fdbe9d2f74c (diff)
Update upstream source from tag 'upstream/20221106+py3'
Update to upstream version '20221106+py3' with Debian dir b54298e303932808cc08745c5f5133ad7b12628e
Diffstat (limited to 'tools/py3_driver_progress.py')
-rw-r--r--tools/py3_driver_progress.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/tools/py3_driver_progress.py b/tools/py3_driver_progress.py
new file mode 100644
index 0000000..52a9e2f
--- /dev/null
+++ b/tools/py3_driver_progress.py
@@ -0,0 +1,96 @@
+#!/usr/bin/python3
+
+import argparse
+import csv
+import sys
+
+from chirp import directory
+
+directory.safe_import_drivers()
+
+
+def tester_link(text):
+ if text.startswith('@'):
+ return '[%s](https://github.com/%s)' % (text, text[1:])
+ elif text.startswith('+'):
+ assert text[1:] in directory.DRV_TO_RADIO, \
+ '%s is not in the driver directory' % text[1:]
+ return '[Implied by %s](#user-content-%s)' % (text[1:], text[1:])
+ else:
+ return text
+
+
+def main():
+ p = argparse.ArgumentParser()
+ p.add_argument('testers')
+ p.add_argument('-o', '--output', default='-')
+ args = p.parse_args()
+
+ headers = ['Driver', 'Tester', 'Tested']
+ testers = {}
+
+ if args.output == '-':
+ output = sys.stdout
+ else:
+ output = open(args.output, 'w')
+
+ line = 0
+ for fields in csv.reader(open(args.testers)):
+ line += 1
+ if fields[0][0] == '#':
+ continue
+
+ if len(fields) != len(headers):
+ print('Error on line %i: invalid number of fields in: %s' % (
+ line, ','.join(fields)),
+ file=sys.stderr)
+ return 1
+
+ if fields[0] in testers:
+ print('Error: duplicate driver %r in testers file' % fields[0],
+ file=sys.stderr)
+ return 2
+
+ testers[fields[0]] = fields[1:]
+
+ print('## Status', file=output)
+
+ print('| Driver | Tester | Tested | Byte Clean |', file=output)
+ print('| ------ | ------ | ------ | ---------- |', file=output)
+
+ drivers = sorted([ident for ident in directory.DRV_TO_RADIO])
+ drvstested = 0
+ byteclean = 0
+ for driver in drivers:
+ cls = directory.get_radio(driver)
+ tester, tested = testers.pop(driver, ('', ''))
+ if tester:
+ drvstested += 1
+ if not cls.NEEDS_COMPAT_SERIAL:
+ byteclean += 1
+ print('| <a name="%s"></a> %s | %s | %s | %s |' % (
+ driver, driver, tester_link(tester), tested,
+ '' if cls.NEEDS_COMPAT_SERIAL else 'Yes'),
+ file=output)
+
+ print('## Stats', file=output)
+ print('\n**Drivers:** %i' % (len(drivers)), file=output)
+ print('\n**Tested:** %i%% (%i/%i)' % (
+ drvstested / len(drivers) * 100,
+ drvstested, len(drivers) - drvstested),
+ file=output)
+ print('\n**Byte clean:** %i%% (%i/%i)' % (
+ byteclean / len(drivers) * 100,
+ byteclean,
+ len(drivers) - byteclean),
+ file=output)
+
+ for driver, (tester, tested) in testers.items():
+ print('Error in testers file; driver %s by %s on %s unknown' % (
+ driver, tester, tested), file=sys.stderr)
+ if testers:
+ return 3
+
+
+if __name__ == '__main__':
+ sys.exit(main())