Modifier
This module provides functionality to modify generated SiLA2 server implementation files. It transforms method bodies that raise NotImplementedError into calls to corresponding methods on an 'original_object' attribute, and ensures that the server implementation file is correctly set up.
CLASS | DESCRIPTION |
---|---|
ImplementationTransformer |
An AST transformer that modifies method bodies in a specific class. |
FUNCTION | DESCRIPTION |
---|---|
copy_from_existing |
Copies the content from an existing SiLA2 implementation or XML file to a new file. |
modify_generated_file |
Modifies the specified Python template file to replace NotImplementedError calls. |
modify_server_file |
Modifies the SiLA2 server implementation file to set the name, description, and server type. |
ImplementationTransformer
Bases: NodeTransformer
Transforms method bodies in a specific class that only raise NotImplementedError into calls to a corresponding method on an 'original_object' attribute.
visit_ClassDef
Visit ClassDef nodes. If it's our target class, set a flag so we know to process its methods.
copy_from_existing
Copies the content from an existing SiLA2 implementation or XML file to a new file.
PARAMETER | DESCRIPTION |
---|---|
filepath
|
Path to the file where content should be copied.
TYPE:
|
library
|
Path to the library directory containing existing SiLA2 files.
TYPE:
|
modify_generated_file
modify_generated_file(
generated_filepath: Path,
target_class_name: str,
object_name: str,
setup_name: str,
) -> str
Modifies the specified Python template file to replace NotImplementedError calls with actual method calls to an original object.
PARAMETER | DESCRIPTION |
---|---|
generated_filepath
|
Path to the generated Python file.
TYPE:
|
target_class_name
|
Name of the class to modify.
TYPE:
|
object_name
|
Name of the object to call methods on.
TYPE:
|
setup_name
|
Name of the setup for which this modification is being done.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The modified code as a string.
TYPE:
|
modify_server_file
Modifies the SiLA2 server implementation file to set the name, description, and server type.
PARAMETER | DESCRIPTION |
---|---|
server_filepath
|
Path to the SiLA2 server implementation file.
TYPE:
|
setup_name
|
Name of the setup for which this modification is being done.
TYPE:
|