graviti.portex.field
#
Portex record field releated classes.
Module Contents#
Classes#
Represents a frozen fields dict. |
|
Represents a Portex |
|
Fields composed of FrozenFields and Fields. |
Attributes#
- class graviti.portex.field.FrozenFields(items=None)[source]#
Bases:
graviti.utility.FrozenNameOrderedDict
[graviti.portex.base.PortexType
]Represents a frozen fields dict.
- Parameters
items (Union[Iterable[Tuple[str, _V]], Mapping[str, _V], None]) –
- insert(self, index, name, portex_type)[source]#
Insert the name and portex_type at the index.
- Parameters
index (int) – The index to insert the field.
name (str) – The name of the field to be inserted.
portex_type (graviti.portex.base.PortexType) – The portex_type of the field to be inserted.
- Raises
TypeError – When calling this method of FrozenFields.
- Return type
None
- astype(self, name, portex_type)[source]#
Convert the type of the field with the given name to the new PortexType.
- Parameters
name (str) – The name of the field to convert.
portex_type (graviti.portex.base.PortexType) – The new PortexType of the field to convert to.
- Raises
TypeError – When calling this method of FrozenFields.
- Return type
None
- class graviti.portex.field.Fields(fields=None)[source]#
Bases:
graviti.utility.NameOrderedDict
[graviti.portex.base.PortexType
],FrozenFields
Represents a Portex
record
fields dict.- Parameters
fields (Union[Iterable[Tuple[str, graviti.portex.base.PortexType]], Mapping[str, graviti.portex.base.PortexType], None]) –
- property imports(self)[source]#
Get the Fields imports.
- Returns
The
Imports
instance of this Fields.- Return type
- insert(self, index, name, portex_type)[source]#
Insert the name and portex_type at the index.
- Parameters
index (int) – The index to insert the field.
name (str) – The name of the field to be inserted.
portex_type (graviti.portex.base.PortexType) – The portex_type of the field to be inserted.
- Raises
KeyError – When the name already exists in the Fields.
- Return type
None
- astype(self, name, portex_type)[source]#
Convert the type of the field with the given name to the new PortexType.
- Parameters
name (str) – The name of the field to convert.
portex_type (graviti.portex.base.PortexType) – The new PortexType of the field to convert to.
- Raises
KeyError – When the name does not exist in the Fields.
- Return type
None
- rename(self, old_name, new_name)[source]#
Rename the name of a field.
- Parameters
old_name (str) – The current name of the field to be renamed.
new_name (str) – The new name of the field to assign.
- Return type
None
- classmethod from_pyobj(cls, content, imports=None)[source]#
Create Portex fields dict instance from python list.
- Parameters
content (List[Dict[str, Any]]) – A python list representing a Portex fields dict.
imports (Optional[graviti.portex.package.Imports]) – The imports of the Portex fields dict.
- Returns
A Portex fields dict instance created from the input python list.
- Return type
- to_pyobj(self)[source]#
Dump the instance to a python list.
- Returns
A Python List representation of the fields dict.
- Return type
List[Dict[str, Any]]
- class graviti.portex.field.ConnectedFields(multi_fields)[source]#
Bases:
MutableMapping
[str
,graviti.portex.base.PortexType
]Fields composed of FrozenFields and Fields.
- Raises
ValueError – When there as repeated field names.
- Parameters
multi_fields (Iterable[UnionFields]) – The FrozenFields and Fields.
- insert(self, index, name, portex_type)[source]#
Insert the name and portex_type at the index.
- Parameters
index (int) – The index to insert the field.
name (str) – The name of the field to be inserted.
portex_type (graviti.portex.base.PortexType) – The portex_type of the field to be inserted.
- Raises
ValueError – When the name already exists in the fields.
TypeError – When trying to insert a field into FrozenFields.
- Return type
None
- astype(self, name, portex_type)[source]#
Convert the type of the field with the given name to the new PortexType.
- Parameters
name (str) – The name of the field to convert.
portex_type (graviti.portex.base.PortexType) – The new PortexType of the field to convert to.
- Return type
None