pymasep.common.object

Classes

Object

Object inside the environment

Module Contents

class pymasep.common.object.Object(environment, name=None, parent=None, xml_node=None, template=None, src_copy=None)

Bases: pymasep.common.base_object.BaseObject

Object inside the environment

Parameters:
  • environment – an Environment instance

  • name (Optional[str]) – name of the Object.

  • xml_node (Optional[xml.etree.ElementTree.Element]) – XML used to create the object.

  • template – Template of the object. Needed if no xml_node.

  • parent (Optional[pymasep.common.base_object.BaseObject]) – Parent object (see objects hierarchy)

  • src_copy (Optional[Object]) – The Intention to copy. Needed if no xml_node or template. The copy is not made into the constructor.

Raises:

pymasep.common.exception.CreationException – If no XML or no template or src_copy is present

__slots__ = ['object_state', 'containers']
object_state = None

the ObjectState of the object

containers

all the containers of the object.

state()

State of the Object. “Init” if the ObjectState or one of its containers is in init state. “Run” if the Object is operational.

Returns:

The state of the Object

Return type:

str

id_str()

Create a string unique ID of the Object. Depends on the content of the base object and the id_str of all characteristics in object_state

Returns:

The string unique ID

Return type:

str

to_xml()

Transform the Object to XML with ObjectState content See Serialization for more information.

Returns:

XML version of the ObjectState

Return type:

xml.etree.ElementTree.Element

from_xml(environment, xml_node)

Transform an XML to an Object. The instance must be created before (with __init__(), passing the xml_node). See Serialization for more information.

Parameters:
  • environment – The environment where the Object is created.

  • xml_node (xml.etree.ElementTree.Element) – The XML node that contains the object information.

Raises:

pymasep.common.exception.CreationException – SubElement must be present if initializer is not present. At creation, Initializer must be present for all characteristics if initializer is not present for ObjectState

Return type:

None

add_object_in_container(obj, container)

Add an Object to a container. This method is currently not used, and some works need to be done to avoid the duplication of objects in state

Parameters:
  • obj – The object to be added.

  • container (str) – The name of the container.

remove_object_from_container(obj)

Remove an Object from its container. Warning: after this method, the object is not attached to anything. Should not be used at the moment. See MDV-72

copy_obs(params)

Deep copy the Object to a new instance.

Parameters:

params (dict) – Not used in this method.

Note : this method copy the reference of the parent. The parent should do the parent copy and assignment