Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix conversion typos #238

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from yaml.scanner import ScannerError


class CPPConverstions:
class CPPConversions:
def __init__(self):
self.defined_type_to_lang_type = {
'none': lambda defined_type, templates: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import os
import yaml

from generate_parameter_library_py.cpp_convertions import CPPConverstions
from generate_parameter_library_py.python_convertions import PythonConvertions
from generate_parameter_library_py.cpp_conversions import CPPConversions
from generate_parameter_library_py.python_conversions import PythonConversions
from generate_parameter_library_py.string_filters_cpp import (
valid_string_cpp,
valid_string_python,
Expand Down Expand Up @@ -162,13 +162,13 @@ def __init__(
default_value: Any,
):
if language == 'cpp':
self.conversation = CPPConverstions()
self.conversion = CPPConversions()
elif language == 'rst' or language == 'markdown':
# cpp is used here because it the desired style of the markdown,
# e.g. "false" for C++ instead of "False" for Python
self.conversation = CPPConverstions()
self.conversion = CPPConversions()
elif language == 'python':
self.conversation = PythonConvertions()
self.conversion = PythonConversions()
else:
raise compile_error(
'Invalid language, only c++ and python are currently supported.'
Expand All @@ -181,21 +181,21 @@ def __init__(
self.defined_type, template = self.process_type(defined_type)
self.array_type = array_type(self.defined_type)

if self.defined_type not in self.conversation.defined_type_to_lang_type:
if self.defined_type not in self.conversion.defined_type_to_lang_type:
allowed = ', '.join(
key for key in self.conversation.defined_type_to_lang_type
key for key in self.conversion.defined_type_to_lang_type
)
raise compile_error(
f'Invalid parameter type `{defined_type}` for parameter {param_name}. Allowed types are: '
+ allowed
)
func = self.conversation.defined_type_to_lang_type[self.defined_type]
func = self.conversion.defined_type_to_lang_type[self.defined_type]
self.lang_type = func(self.defined_type, template)
tmp = defined_type.split('_')
self.defined_base_type = tmp[0]
func = self.conversation.defined_type_to_lang_type[self.defined_base_type]
func = self.conversion.defined_type_to_lang_type[self.defined_base_type]
self.lang_base_type = func(self.defined_base_type, template)
func = self.conversation.lang_str_value_func[self.defined_type]
func = self.conversion.lang_str_value_func[self.defined_type]
try:
self.lang_str_value = func(default_value)
except TypeCheckError:
Expand All @@ -204,18 +204,18 @@ def __init__(
)

def parameter_as_function_str(self):
if self.defined_type not in self.conversation.yaml_type_to_as_function:
if self.defined_type not in self.conversion.yaml_type_to_as_function:
raise compile_error('invalid yaml type: %s' % type(self.defined_type))
return self.conversation.yaml_type_to_as_function[self.defined_type]
return self.conversion.yaml_type_to_as_function[self.defined_type]

def get_python_val_to_str_func(self, arg):
return self.conversation.python_val_to_str_func[str(type(arg))]
return self.conversion.python_val_to_str_func[str(type(arg))]

def get_yaml_type_from_python(self, arg):
if isinstance(arg, list):
return self.conversation.python_list_to_yaml_type[str(type(arg[0]))]
return self.conversion.python_list_to_yaml_type[str(type(arg[0]))]
else:
return self.conversation.python_val_to_yaml_type[str(type(arg[0]))]
return self.conversion.python_val_to_yaml_type[str(type(arg[0]))]

def process_type(self, defined_type):
raise NotImplemented()
Expand All @@ -237,7 +237,7 @@ def process_type(self, defined_type):
size = fixed_type_size(defined_type)
tmp = defined_type.split('_')
yaml_base_type = tmp[0]
func = self.conversation.defined_type_to_lang_type[yaml_base_type]
func = self.conversion.defined_type_to_lang_type[yaml_base_type]
lang_base_type = func(yaml_base_type, None)
defined_type = get_fixed_type(defined_type)
return defined_type, (lang_base_type, size)
Expand Down Expand Up @@ -335,11 +335,11 @@ def __init__(
self.arguments = []

def __str__(self):
function_name = self.code_gen_variable.conversation.get_func_signature(
function_name = self.code_gen_variable.conversion.get_func_signature(
self.function_name, self.code_gen_variable.lang_base_type
)
open_bracket = self.code_gen_variable.conversation.open_bracket
close_bracket = self.code_gen_variable.conversation.close_bracket
open_bracket = self.code_gen_variable.conversion.open_bracket
close_bracket = self.code_gen_variable.conversion.close_bracket

code = function_name + '(param'
for arg in self.arguments:
Expand Down Expand Up @@ -511,7 +511,7 @@ def __str__(self):
self.parameter_value = ''
else:
self.parameter_value = self.parameter_name
bool_to_str = self.code_gen_variable.conversation.bool_to_str
bool_to_str = self.code_gen_variable.conversion.bool_to_str

parameter_validations = self.parameter_validations

Expand Down Expand Up @@ -568,7 +568,7 @@ def __str__(self):
else:
default_value = 'non-empty'

bool_to_str = self.code_gen_variable.conversation.bool_to_str
bool_to_str = self.code_gen_variable.conversion.bool_to_str
parameter_field = get_dynamic_parameter_field(self.parameter_name)
mapped_params = get_dynamic_mapped_parameter(self.parameter_name)
parameter_map = get_dynamic_parameter_map(self.parameter_name)
Expand Down Expand Up @@ -790,16 +790,16 @@ def parse_params(self, name, value, nested_name_list):

param_name = code_gen_variable.param_name
update_parameter_invalid = (
code_gen_variable.conversation.update_parameter_fail_validation()
code_gen_variable.conversion.update_parameter_fail_validation()
)
update_parameter_valid = (
code_gen_variable.conversation.update_parameter_pass_validation()
code_gen_variable.conversion.update_parameter_pass_validation()
)
declare_parameter_invalid = (
code_gen_variable.conversation.initialization_fail_validation(param_name)
code_gen_variable.conversion.initialization_fail_validation(param_name)
)
declare_parameter_valid = (
code_gen_variable.conversation.initialization_pass_validation(param_name)
code_gen_variable.conversion.initialization_pass_validation(param_name)
)

# add variable to struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from yaml.scanner import ScannerError


class PythonConvertions:
class PythonConversions:
def __init__(self):
self.defined_type_to_lang_type = {
'none': lambda defined_type, templates: None,
Expand Down
Loading