h5rdmtoolbox.convention.StandardAttribute

h5rdmtoolbox.convention.StandardAttribute#

class h5rdmtoolbox.convention.StandardAttribute(name, *, description, validator, target_method=None, default_value=_SpecialDefaults.EMPTY, alternative_standard_attribute=None, position=None, requirements=None, type_hint=None, rdf_predicate=None, frdf_predicate=None, **kwargs)[source]#

StandardAttribute class for the standardized attributes

Parameters:
  • name (str) – The name of the attribute

  • validator (Union[pydantic.BaseModel, typing_extensions._AnnotatedAlias]) – The validator for the attribute. If the validator takes a parameter, pass it as dict. Examples for no-parameter validator: “$pintunits”, “$standard_name”, “$orcid”, “$url” Examples for validator with parameter: {“$regex”: r”^[a-z0-9_]*$”}, {“$in”: [“a”, “b”, “c”]}

  • description (str) – The description of the attribute

  • target_method (str) – The method to which the attribute belongs, e.g. “create_group”. Valid values are “create_group”, “create_dataset”, “__init__”.

  • default_value (any, optional=DefaultValue.EMPTY) – If the attribute is positional, it has no default value, then pass DefaultValue.EMPTY (the default). Otherwise, pass the default value. The default value applies to all methods to which the attribute applies.

  • alternative_standard_attribute; str, optional=None – The name of the alternative standard attribute. If the attribute is not present, the alternative standard attribute is used. If None (default), no alternative standard attribute is defined.

  • position (int, optional=None) – The position of the attribute. None puts it at the end.

  • requirements (List[str] = None,) – The requirements for the attribute. Values are other standard names used in the convention. If None (default), no requirements are defined.

__init__(name, *, description, validator, target_method=None, default_value=_SpecialDefaults.EMPTY, alternative_standard_attribute=None, position=None, requirements=None, type_hint=None, rdf_predicate=None, frdf_predicate=None, **kwargs)[source]#

Methods

__init__(name, *, description, validator[, ...])

get(parent)

Read the attribute from parent

is_obligatory()

is an obligatory attribute

is_optional()

has no default value

is_positional()

has no default value

make_optional()

make this standard attribute optional by setting the default value to Default.NONE

set(parent, value[, attrs])

Write value to attribute of parent

validate(value[, parent, attrs])

Attributes

EMPTY

METHOD_CLS_ASSIGNMENT

NONE

PROPERTY_CLS_ASSIGNMENT

VALID_TARGET_METHODS