From c568a3a56692aa04c4aa6d561858a3563974b4ab Mon Sep 17 00:00:00 2001 From: kosheverov Date: Tue, 27 Jun 2023 17:26:41 +0300 Subject: [PATCH] support param_name_case in dataProvider for TS --- .../type_script/dict_tracker_generator.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/evgen/code_generators/type_script/dict_tracker_generator.py b/src/evgen/code_generators/type_script/dict_tracker_generator.py index 9035129..a13145d 100644 --- a/src/evgen/code_generators/type_script/dict_tracker_generator.py +++ b/src/evgen/code_generators/type_script/dict_tracker_generator.py @@ -179,9 +179,13 @@ def _generate_class_interfaces(self, code: evgen_code.Code): ) ] - statements.extend(self._get_params_class(code.global_params)) + statements.extend( + self._get_params_class(code.global_params, self.param_name_case) + ) statements.append(st.EmptyLine()) - statements.extend(self._get_params_class(code.platform_params)) + statements.extend( + self._get_params_class(code.platform_params, self.param_name_case) + ) statements.append(st.EmptyLine()) class_statement = st.Closure( @@ -261,7 +265,9 @@ def _generate_namespace(self, namespace: str, functions: List[evgen_code.Functio helpers.write_statements(statements, fp) def _get_params_class( - self, global_params: Union[evgen_code.GlobalParams, evgen_code.PlatformParams] + self, + global_params: Union[evgen_code.GlobalParams, evgen_code.PlatformParams], + param_name_case: str, ) -> List[st.Statement]: gp_statements = list() @@ -276,13 +282,16 @@ def _get_params_class( class_statements = list() # public parameters for param in global_params.params: + param_name = ( + param.code_name if param_name_case == "camel_case" else param.event_name + ) if not isinstance(param.type, evgen_code.ConstType): class_statements.append( - st.Line(f"{param.code_name}: {param.type.declaration()}") + st.Line(f"{param_name}: {param.type.declaration()}") ) else: class_statements.append( - st.Line(f'{param.code_name}: "{param.type.type_value}"') + st.Line(f'{param_name}: "{param.type.type_value}"') ) gp_statements.append(