The api_serialization.py module#

Summary#

ToAPIStringVisitor

Visits values and converts them to an API string.

to_api_string

Convert a variable value to an API string.

from_api_string

Generate a value from an API string.

Description#

Defines the ToAPIStringVisitor class.

Module detail#

api_serialization.to_api_string(value: ansys.tools.variableinterop.variable_value.IVariableValue, save_context: ansys.tools.variableinterop.isave_context.ISaveContext | None = None) str#

Convert a variable value to an API string.

Parameters:
valueIVariableValue

Value to convert to an API string.

save_contextOptional[ISaveContext], optional

Save context to use for conversion. The default value is None, which indicates that you do not want to support file values.

Returns:
str

Serialized form of the value.

api_serialization.from_api_string(var_type: ansys.tools.variableinterop.variable_type.VariableType, source: str, fscope: ansys.tools.variableinterop.file_scope.FileScope | None = None, load_context: ansys.tools.variableinterop.isave_context.ILoadContext | None = None) ansys.tools.variableinterop.variable_value.IVariableValue#

Generate a value from an API string.

Parameters:
var_typeVariableType

Variable type to generate.

sourcestr

Source string.

fscopeOptional[FileScope], optional

File scope to use to deserialize file variables. The default is None, which indictates that file variables are not needed.

load_contextOptional[ILoadContext], optional

Load context to read file contents from. The default is None, which indicates file variables are not needed.

Returns:
IVariableValue

Implementation of IVariableValue of the correct type with a value parsed from the specified string.