conkit.core.entity module

Entity container used throughout ConKit

class Entity(id)[source]

Bases: object

Base class for all entities used in this interface.

It handles the storage of data. It also provides a high-efficiency methods to allow fast lookup and iterations of each entity. It also provides a hierarchical structure to remember parent and child entities.

Warning

It is strongly advised against the use of the Entity class directly. Instead, use one or more of the the remaining data models.

id

The ID of the selected entity

Type:str, list, tuple
full_id

A traceback id including all parent classes

Type:tuple
parent

An attribute to store the reference to the parent Entity

Type:Entity
child_list

A list storing the child entities

Type:list
child_dict

A dictionary storing the child entities

Type:dict
add(entity)[source]

Add a child to the Entity

Parameters:entity (Entity) –
child_dict
child_list
copy()[source]

Create a shallow copy of Entity

deepcopy()[source]

Create a deep copy of Entity

full_id

A traceback id including all parent classes

The full id is a tuple containing all id’s starting from the top object (ContactFile) down to the current object. A full id for a Contact e.g. is something like: (‘1aa’, 1, (1, 10))

This corresponds to:

ContactFile identifier => 1aaa ContactMap identifier => 1 Contact identifier => (1, 10)

id

The ID of the selected entity

static listify(s)[source]

Convert unknown input to a list

Parameters:s (str, int, float, list, tuple) –
Returns:The input as list
Return type:list
parent
remove(id)[source]

Remove a child

Parameters:id (str, int, list, tuple) –

Warning

If id is of type int, then the Entity in the child_list` at index id will be deleted

top

The first child in the Entity