From 8e86d66238572c1d97cd54a592da0573a51892a1 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 3 Dec 2023 17:47:36 -0700 Subject: updated MODELS, bin/models.py, and hw/BRANDS... - changed column order to (model, mcu, name) - changed column sizes (auto-sized w/ 2 spaces between columns) - made it handle hex digits in model numbers - reserved 1900 to 2199 for years only, not model numbers - noted gChart and thefreeman sharing a brand ID --- bin/models.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'bin/models.py') diff --git a/bin/models.py b/bin/models.py index 8e54d1c..1a1152e 100755 --- a/bin/models.py +++ b/bin/models.py @@ -24,12 +24,18 @@ def main(args): foo.sort() models = [x[-1] for x in foo] + colsizes = [ + max(len(m.model) for m in models), + max(len(m.mcu) for m in models), + max(len(m.name) for m in models), + ] + print('Models: %i\n' % len(models)) - fmt = '%s\t%-30s\t%s' - print(fmt % ('Model', 'Name', 'MCU')) - print(fmt % ('-----', '----', '---')) + fmt = '%%-%is %%-%is %%s' % (colsizes[0], colsizes[1]) + print(fmt % ('Model', 'MCU', 'Name')) + print(fmt % ('-----', '---', '----')) for m in models: - print(fmt % (m.model, m.name, m.mcu)) + print(fmt % (m.model, m.mcu, m.name)) print('\nDuplicates:') for i, m in enumerate(models): @@ -56,6 +62,7 @@ def load_model(path): m.name = path.replace('hw/','').replace('/', '-') m.mcu = inherit(path, 'arch') m.model = inherit(path, 'model') + if m.model: m.model = model_translate(m.model) return m @@ -73,6 +80,24 @@ def inherit(path, field): return None +def model_translate(m): + """Convert raw ordinal hex codes into human-friendly a-f digits. + """ + m = str(m) + replace = { + chr(ord('0') + 10): 'a', + chr(ord('0') + 11): 'b', + chr(ord('0') + 12): 'c', + chr(ord('0') + 13): 'd', + chr(ord('0') + 14): 'e', + chr(ord('0') + 15): 'f', + } + for s, r in replace.items(): + m = m.replace(s, r) + + return m + + if __name__ == "__main__": import sys main(sys.argv[1:]) -- cgit v1.2.3