tensorbay.utility.attr
AttrsMixin and Field class.
AttrsMixin
provides a list of special methods based on field configs.
Field
is a class describing the attr related fields.
- class tensorbay.utility.attr.Field(*, is_dynamic, key, default, error_message, loader, dumper)[source]
Bases:
object
A class to identify attr fields.
- Parameters
is_dynamic (bool) – Whether attr is a dynamic attr.
key (Union[str, None, Callable[[str], str]]) – Display value of the attr in contents.
default (Any) – Default value of the attr.
error_message (Optional[str]) – The custom error message of the attr.
loader (Optional[Callable[[Any], Any]]) – The custom loader of the attr.
dumper (Optional[Callable[[Any], Any]]) – The custom dumper of the attr.
- Return type
None
- class tensorbay.utility.attr.BaseField(key)[source]
Bases:
object
A class to identify fields of base class.
- Parameters
key (Optional[str]) – Display value of the attr.
- Return type
None
- class tensorbay.utility.attr.AttrsMixin[source]
Bases:
object
AttrsMixin provides a list of special methods based on attr fields.
Examples
box2d: Box2DSubcatalog = attr(is_dynamic=True, key=”BOX2D”)
- tensorbay.utility.attr.attr(*, is_dynamic=False, key=<function <lambda>>, default=Ellipsis, error_message=None, loader=None, dumper=None)[source]
Return an instance to identify attr fields.
- Parameters
is_dynamic (bool) – Determine if this is a dynamic attr.
key (Union[str, None, Callable[[str], str]]) – Display value of the attr in contents.
default (Any) – Default value of the attr.
error_message (Optional[str]) – The custom error message of the attr.
loader (Optional[Callable[[Any], Any]]) – The custom loader of the attr.
dumper (Optional[Callable[[Any], Any]]) – The custom dumper of the attr.
- Raises
AttrError – Dynamic attr cannot have default value.
- Returns
A
Field
instance containing all attr fields.- Return type
Any
- tensorbay.utility.attr.attr_base(key=None)[source]
Return an instance to identify base class fields.
- Parameters
key (Optional[str]) – Display value of the attr.
- Returns
A
BaseField
instance containing all base class fields.- Return type
Any