diff options
Diffstat (limited to 'codegen/lib/code/utils.py')
| -rw-r--r-- | codegen/lib/code/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/codegen/lib/code/utils.py b/codegen/lib/code/utils.py index e4671488..d91e0634 100644 --- a/codegen/lib/code/utils.py +++ b/codegen/lib/code/utils.py @@ -147,3 +147,17 @@ def write_packet_file(state, packet_name_snake_case, code): def fmt(): os.system(f'cd {get_dir_location("..")} && cargo fmt') + + +def clean_property_name(property_name): + # if the name ends with _<number>, remove that part + ending = property_name.split('_')[-1] + if ending.isdigit(): + property_name = property_name[:-(len(ending) + 1)] + + # `type` is a reserved keyword, so we use kind instead ¯\_(ツ)_/¯ + if property_name == 'type': + property_name = 'kind' + + return property_name + |
