gemd.entity.setters module

Methods for setting and validating.

gemd.entity.setters.validate_list(obj: Optional[Union[Iterable[T], T]], typ: Union[Iterable[Type], Type], *, trigger: Optional[Callable[[T], Optional[T]]] = None) ValidList

Attempts to return obj as a list, each element of which has type typ.

Parameters
  • obj (Any) – Object or list of objects, all of which should be of type typ.

  • typ (Type) – The desired type of obj, or if obj is a list, every element of obj.

  • trigger (function) – A function to invoke when putting obj into a list.

Returns

A list with all elements of obj. The list is constrained so that every element has type typ.

Return type

ValidList

gemd.entity.setters.validate_str(obj) str

Check that obj is a string and then convert it to unicode.

Parameters

obj (Any) – Object that should be a string

Returns

obj as a string.

Return type

str

Raises

ValueError – If obj is not a string.