From c547a9628f6c1615de28fc2c76719d0d616d273e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 14 Aug 2024 22:59:53 -0700 Subject: [PATCH] remove the struct converter --- selfdrive/car/capnp_to_dataclass.py | 53 ----------------------------- 1 file changed, 53 deletions(-) delete mode 100644 selfdrive/car/capnp_to_dataclass.py diff --git a/selfdrive/car/capnp_to_dataclass.py b/selfdrive/car/capnp_to_dataclass.py deleted file mode 100644 index ca6243e176..0000000000 --- a/selfdrive/car/capnp_to_dataclass.py +++ /dev/null @@ -1,53 +0,0 @@ -import re - -TYPE_MAP = { - 'Text': 'str', - 'Bool': 'bool', - 'Int8': 'int', - 'Int16': 'int', - 'UInt32': 'int', - 'UInt64': 'int', - 'Float32': 'float', - 'Data': 'bytes', - 'List': 'list', -} - -TXT = """ -""" - -if __name__ == '__main__': - - if not TXT.strip(): - TXT = input('Paste one struct only') - - in_struct = False - - builder = [] - - for line in TXT.splitlines(): - line = line.strip() - if re.search(':.*;', line): - if not in_struct: - # print(line) - name, typ, cmt = re.search('([a-zA-Z]+)\s*@\s*\d+\s*:\s*([a-zA-Z0-9\(\)]+)(?:.*#(.*))?', line.strip()).groups() # type: ignore # noqa - # print((name, typ, cmt)) - if name.endswith('DEPRECATED'): - continue - - if 'List' in typ: - second_typ = typ.split("(")[1][:-1] - typ = f'list[{TYPE_MAP.get(second_typ, second_typ)}]' - - new_typ = TYPE_MAP.get(typ, typ) - # print(f' {name}: {new_typ} = auto_field()') - # print() - new_cmt = f' # {cmt.strip()}' if cmt else '' - builder.append(f' {name}: {new_typ} = auto_field(){new_cmt}') - elif re.search('{', line): - in_struct = True - elif re.search('}', line): - in_struct = False - elif line == '': - builder.append('') - - print('\n'.join(builder))