Skip to content

Commit

Permalink
Harmonize naming of methods
Browse files Browse the repository at this point in the history
- Some method names starting with 'make_' changed to 'create_'
  • Loading branch information
cogu committed Feb 5, 2024
1 parent 29dba7c commit 33b18bf
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 97 deletions.
8 changes: 4 additions & 4 deletions examples/xml/port_interface/client_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def create_port_interfaces(packages: dict[str, ar_element.Package]):
"""
uint32_impl_type = packages["PlatformImplementationDataTypes"].find("uint32")
interface = ar_element.ClientServerInterface("FreeRunningTimer_I", is_service=True)
operation = interface.make_operation("GetTimeStamp")
operation.make_out_argument("value",
ar_enum.ServerArgImplPolicy.USE_ARGUMENT_TYPE,
type_ref=uint32_impl_type.ref())
operation = interface.create_operation("GetTimeStamp")
operation.create_out_argument("value",
ar_enum.ServerArgImplPolicy.USE_ARGUMENT_TYPE,
type_ref=uint32_impl_type.ref())
packages["PortInterfaces"].append(interface)


Expand Down
6 changes: 3 additions & 3 deletions examples/xml/port_interface/nv_data_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create_nv_data_interface_with_one_element(packages: dict[str, ar_element.Pac
"""
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8")
portinterface = ar_element.NvDataInterface("DataInterface1")
portinterface.make_data_element("Data1", type_ref=uint8_type.ref())
portinterface.create_data_element("Data1", type_ref=uint8_type.ref())
packages["PortInterfaces"].append(portinterface)


Expand All @@ -42,8 +42,8 @@ def create_nv_data_interface_with_two_elements(packages: dict[str, ar_element.Pa
"""
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8")
portinterface = ar_element.NvDataInterface("DataInterface2")
portinterface.make_data_element("Data1", type_ref=uint8_type.ref())
portinterface.make_data_element("Data2", type_ref=uint8_type.ref())
portinterface.create_data_element("Data1", type_ref=uint8_type.ref())
portinterface.create_data_element("Data2", type_ref=uint8_type.ref())
packages["PortInterfaces"].append(portinterface)


Expand Down
6 changes: 3 additions & 3 deletions examples/xml/port_interface/parameter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create_parameter_interface_with_one_parameter(packages: dict[str, ar_element
"""
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8")
portinterface = ar_element.ParameterInterface("ParameterInterface1")
portinterface.make_parameter("Param1", type_ref=uint8_type.ref())
portinterface.create_parameter("Param1", type_ref=uint8_type.ref())
packages["PortInterfaces"].append(portinterface)


Expand All @@ -42,8 +42,8 @@ def create_parameter_interface_with_two_parameters(packages: dict[str, ar_elemen
"""
uint8_type: ar_element.ImplementationDataType = packages["PlatformImplementationDataTypes"].find("uint8")
portinterface = ar_element.ParameterInterface("ParameterInterface2")
portinterface.make_parameter("Param1", type_ref=uint8_type.ref())
portinterface.make_parameter("Param2", type_ref=uint8_type.ref())
portinterface.create_parameter("Param1", type_ref=uint8_type.ref())
portinterface.create_parameter("Param2", type_ref=uint8_type.ref())
packages["PortInterfaces"].append(portinterface)


Expand Down
6 changes: 3 additions & 3 deletions examples/xml/port_interface/sender_receiver_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_sender_receiver_interface_with_one_element(packages: dict[str, ar_ele
"""
inactive_active_t = packages["ImplementationDataTypes"].find("InactiveActive_T")
portinterface = ar_element.SenderReceiverInterface("HeadLightStatus_I")
portinterface.make_data_element("HeadLightStatus", type_ref=inactive_active_t.ref())
portinterface.create_data_element("HeadLightStatus", type_ref=inactive_active_t.ref())
packages["PortInterfaces"].append(portinterface)


Expand All @@ -53,8 +53,8 @@ def create_sender_receiver_interface_with_two_elements(packages: dict[str, ar_el
"""
inactive_active_t = packages["ImplementationDataTypes"].find("InactiveActive_T")
portinterface = ar_element.SenderReceiverInterface("InterfaceName")
portinterface.make_data_element("Element1", type_ref=inactive_active_t.ref())
portinterface.make_data_element("Element2", type_ref=inactive_active_t.ref())
portinterface.create_data_element("Element1", type_ref=inactive_active_t.ref())
portinterface.create_data_element("Element2", type_ref=inactive_active_t.ref())
packages["PortInterfaces"].append(portinterface)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "autosar"
version = "0.5.1"
version = "0.5.2a1"
description = "A set of Python modules for working with AUTOSAR XML files"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
100 changes: 50 additions & 50 deletions src/autosar/xml/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -3057,9 +3057,9 @@ def __init__(self,
if isinstance(mode_declaration, ModeDeclaration):
self.append_mode_declaratation(mode_declaration)
elif isinstance(mode_declaration, str):
self.make_mode_declaration(mode_declaration)
self.create_mode_declaration(mode_declaration)
elif isinstance(mode_declaration, tuple):
self.make_mode_declaration(*mode_declaration)
self.create_mode_declaration(*mode_declaration)
else:
err_msg = f"Invalid type '{str(type(mode_declaration))}'"
raise TypeError(err_msg + ". " + expected_types)
Expand Down Expand Up @@ -3100,10 +3100,10 @@ def append_mode_declaratation(self, mode_declaration: ModeDeclaration) -> None:
msg = f"mode_declaration: Invalid type '{str(type(mode_declaration))}'"
raise TypeError(msg + ". Expected 'ModeDeclaration'")

def make_mode_declaration(self,
name: str,
value: int | None = None,
**kwargs) -> ModeDeclaration:
def create_mode_declaration(self,
name: str,
value: int | None = None,
**kwargs) -> ModeDeclaration:
"""
Convenience method for creating a new mode declaration within this group
"""
Expand Down Expand Up @@ -3251,20 +3251,20 @@ def append_invalidation_policy(self, invalidation_policy: InvalidationPolicy):
msg = f"invalidation_policy: Invalid type '{str(type(invalidation_policy))}'"
raise TypeError(msg + ". Expected 'InvalidationPolicy'")

def make_data_element(self,
name: str,
init_value: ValueSpeficationElement | None = None,
**kwargs) -> VariableDataPrototype:
def create_data_element(self,
name: str,
init_value: ValueSpeficationElement | None = None,
**kwargs) -> VariableDataPrototype:
"""
Convenience method for adding a new data element to this port interface
"""
data_element = VariableDataPrototype(name, init_value, **kwargs)
self.append_data_element(data_element)
return data_element

def make_invalidation_policy(self,
data_element_ref: VariableDataPrototypeRef | str,
handle_invalid: ar_enum.HandleInvalid) -> InvalidationPolicy:
def create_invalidation_policy(self,
data_element_ref: VariableDataPrototypeRef | str,
handle_invalid: ar_enum.HandleInvalid) -> InvalidationPolicy:
"""
Convenience method for adding a new invalidation policy to this port interface
"""
Expand Down Expand Up @@ -3314,10 +3314,10 @@ def append_data_element(self, nv_data: VariableDataPrototype):
msg = f"nv_data: Invalid type '{str(type(nv_data))}'"
raise TypeError(msg + ". Expected 'VariableDataPrototype'")

def make_data_element(self,
name: str,
init_value: ValueSpeficationElement | None = None,
**kwargs) -> VariableDataPrototype:
def create_data_element(self,
name: str,
init_value: ValueSpeficationElement | None = None,
**kwargs) -> VariableDataPrototype:
"""
Convenience method for adding a new data element to this port interface
"""
Expand Down Expand Up @@ -3359,10 +3359,10 @@ def append_parameter(self, parameter: ParameterDataPrototype):
msg = f"parameter: Invalid type '{str(type(parameter))}'"
raise TypeError(msg + ". Expected 'ParameterDataPrototype'")

def make_parameter(self,
name: str,
init_value: ValueSpeficationElement | None = None,
**kwargs) -> ParameterDataPrototype:
def create_parameter(self,
name: str,
init_value: ValueSpeficationElement | None = None,
**kwargs) -> ParameterDataPrototype:
"""
Convenience method for adding a new parameter to this port interface
"""
Expand Down Expand Up @@ -3440,44 +3440,44 @@ def append_argument(self, argument: ArgumentDataPrototype) -> None:
msg = f"argument: Invalid type '{str(type(argument))}'"
raise TypeError(msg + ". Expected 'ArgumentDataPrototype'")

def make_argument(self,
name: str,
direction: ar_enum.ArgumentDirection | None = None,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
def create_argument(self,
name: str,
direction: ar_enum.ArgumentDirection | None = None,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
"""
Convenience method for adding a new argument to this operation
"""
argument = ArgumentDataPrototype(name, direction, server_arg_impl_policy, **kwargs)
self.append_argument(argument)
return argument

def make_in_argument(self,
name: str,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
def create_in_argument(self,
name: str,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
"""
Convenience method for adding a new in-argument to this operation
"""
argument = ArgumentDataPrototype(name, ar_enum.ArgumentDirection.IN, server_arg_impl_policy, **kwargs)
self.append_argument(argument)
return argument

def make_inout_argument(self,
name: str,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
def create_inout_argument(self,
name: str,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
"""
Convenience method for adding a new inout-argument to this operation
"""
argument = ArgumentDataPrototype(name, ar_enum.ArgumentDirection.INOUT, server_arg_impl_policy, **kwargs)
self.append_argument(argument)
return argument

def make_out_argument(self,
name: str,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
def create_out_argument(self,
name: str,
server_arg_impl_policy: ar_enum.ServerArgImplPolicy | None = None,
**kwargs) -> ArgumentDataPrototype:
"""
Convenience method for adding a new out-argument to this operation
"""
Expand All @@ -3495,7 +3495,7 @@ def append_possible_error_ref(self, possible_error_ref: ApplicationErrorRef) ->
msg = f"argument: Invalid type '{str(type(possible_error_ref))}'"
raise TypeError(msg + ". Expected 'ApplicationErrorRef'")

def make_possible_error_ref(self, value: str) -> ApplicationErrorRef:
def create_possible_error_ref(self, value: str) -> ApplicationErrorRef:
"""
Convenience method for creating and adding a new possible error reference to this operation
"""
Expand Down Expand Up @@ -3559,13 +3559,13 @@ def append_possible_errors(self, possible_error: ApplicationError) -> None:
msg = f"operation: Invalid type '{str(type(possible_error))}'"
raise TypeError(msg + ". Expected 'ApplicationError'")

def make_operation(self,
name: str,
arguments: ArgumentDataPrototype | list[ArgumentDataPrototype] | None = None,
diag_arg_integrity: bool | None = None,
fire_and_forget: bool | None = None,
possible_error_refs: ApplicationErrorRef | list[ApplicationErrorRef] | None = None,
**kwargs) -> ClientServerOperation:
def create_operation(self,
name: str,
arguments: ArgumentDataPrototype | list[ArgumentDataPrototype] | None = None,
diag_arg_integrity: bool | None = None,
fire_and_forget: bool | None = None,
possible_error_refs: ApplicationErrorRef | list[ApplicationErrorRef] | None = None,
**kwargs) -> ClientServerOperation:
"""
Convenience method for creating a new operation in this port interface
"""
Expand All @@ -3574,10 +3574,10 @@ def make_operation(self,
self.append_operation(operation)
return operation

def make_possible_error(self,
name: str,
error_code: int | None = None,
**kwargs) -> ApplicationError:
def create_possible_error(self,
name: str,
error_code: int | None = None,
**kwargs) -> ApplicationError:
"""
Convenience-method for creating a new possible error in this port interface
"""
Expand Down
Loading

0 comments on commit 33b18bf

Please sign in to comment.