Fix build of generated game msgs
the vote status field `pass` conflicts with the python keyword so rename it to `pass_` also fix `get_string()` not being a function
This commit is contained in:
parent
bfa8162aa1
commit
e22530743c
|
@ -35,11 +35,19 @@ class SpecJson(TypedDict):
|
|||
game_enumerations: list[GameEnumJson]
|
||||
game_messages: list[GameMessageJson]
|
||||
|
||||
def fix_name_conflict(name: str) -> str:
|
||||
# https://peps.python.org/pep-0008/#descriptive-naming-styles
|
||||
if name == 'pass':
|
||||
return 'pass_'
|
||||
return name
|
||||
|
||||
def name_to_camel(name_list: list[str]) -> str:
|
||||
return ''.join([part.capitalize() for part in name_list])
|
||||
name = ''.join([part.capitalize() for part in name_list])
|
||||
return fix_name_conflict(name)
|
||||
|
||||
def name_to_snake(name_list: list[str]) -> str:
|
||||
return '_'.join(name_list)
|
||||
name = '_'.join(name_list)
|
||||
return fix_name_conflict(name)
|
||||
|
||||
def generate_msg(msg: GameMessageJson) -> None:
|
||||
name_snake = name_to_snake(msg['name'])
|
||||
|
@ -143,7 +151,7 @@ def generate_msg(msg: GameMessageJson) -> None:
|
|||
# {'name': ['message'], 'type': {'kind': 'string', 'disallow_cc': False}}
|
||||
unpacker = 'int()'
|
||||
if member['type']['kind'] == 'string': # TODO: sanitize cc
|
||||
unpacker = 'string()'
|
||||
unpacker = 'str()'
|
||||
elif member['type']['kind'] == 'raw':
|
||||
unpacker = 'raw()'
|
||||
# {"name": ["mode"], "type": {"kind": "enum", "enum": ["chat"]}},
|
||||
|
|
Loading…
Reference in a new issue