Skip to content

dp3.common.datatype

AnyEidT module-attribute

AnyEidT = Union[str, int, IPv4Address, IPv6Address, MACAddress]

Type alias for any of possible entity ID data types.

Note that the type is determined based on the loaded entity configuration and in most cases is only one of the options, based on what entity is being processed.

ReadOnly

Bases: BaseModel

The ReadOnly data_type is used to avoid datapoint insertion for an attribute.

DataType

Bases: RootModel

Data type container

Represents one of primitive data types:

  • tag
  • binary
  • string
  • int
  • int64
  • float
  • ipv4
  • ipv6
  • mac
  • time
  • special
  • json

or composite data type:

  • link
  • array
  • set
  • dict
  • category

data_type property

data_type: Union[type, BaseModel]

Type for incoming value validation

type_info property

type_info: str

String representation of the data type, immune to whitespace changes

hashable property

hashable: bool

Whether contained data is hashable

iterable property

iterable: bool

Whether the data type is iterable

elem_type property

elem_type: DataType

if iterable, the element data type

is_link: bool

Whether the data type is a link between entities

mirror_link: bool

If is_link, whether the link is mirrored

mirror_as property

mirror_as: Union[str, None]

If mirror_link, what is the name of the mirrored attribute

link_to: str

If is_link, the target linked entity

determine_value_validator

determine_value_validator()

Determines value validator (inner data_type).

Source code in dp3/common/datatype.py
@model_validator(mode="after")
def determine_value_validator(self):
    """Determines value validator (inner `data_type`)."""
    return self._determine_value_validator()

get_linked_entity

get_linked_entity() -> str

Returns linked entity id. Raises ValueError if DataType is not a link.

Source code in dp3/common/datatype.py
def get_linked_entity(self) -> str:
    """Returns linked entity id. Raises ValueError if DataType is not a link."""
    try:
        return self._link_to
    except AttributeError:
        raise ValueError(f"DataType '{self}' is not a link.") from None
link_has_data() -> bool

Whether link has data. Raises ValueError if DataType is not a link.

Source code in dp3/common/datatype.py
def link_has_data(self) -> bool:
    """Whether link has data. Raises ValueError if DataType is not a link."""
    try:
        return self._link_data
    except AttributeError:
        raise ValueError(f"DataType '{self}' is not a link.") from None

EidDataType

Bases: DataType

Data type container for entity id

Represents one of primitive data types: - string - int - ipv4 - ipv6 - mac