tensorbay.utility.name

NameMixin, SortedNameList and NameList.

NameMixin is a mixin class for instance which has immutable name and mutable description.

SortedNameList is a sorted sequence class which contains NameMixin. It is maintained in sorted order according to the ‘name’ of NameMixin.

NameList is a list of named elements, supports searching the element by its name.

class tensorbay.utility.name.NameMixin(name: str, description: str = '')[source]

Bases: tensorbay.utility.attr.AttrsMixin, tensorbay.utility.repr.ReprMixin

A mixin class for instance which has immutable name and mutable description.

Parameters
  • name – Name of the class.

  • description – Description of the class.

name

Name of the class.

class tensorbay.utility.name.NameList(values: Iterable[tensorbay.utility.name._T] = ())[source]

Bases: tensorbay.utility.user.UserSequence[tensorbay.utility.name._T]

NameList is a list of named elements, supports searching the element by its name.

keys() Tuple[str, ...][source]

Get all element names.

Returns

A tuple containing all elements names.

append(value: tensorbay.utility.name._T) None[source]

Append element to the end of the NameList.

Parameters

value – Element to be appended to the NameList.

Raises

KeyError – When the name of the appending object already exists in the NameList.

class tensorbay.utility.name.SortedNameList[source]

Bases: tensorbay.utility.user.UserSequence[tensorbay.utility.name._T]

SortedNameList is a sorted sequence which contains element with name.

It is maintained in sorted order according to the ‘name’ attr of the element.

add(value: tensorbay.utility.name._T) None[source]

Store element in name sorted list.

Parameters

value – The element needs to be added to the list.

Raises

KeyError – If the name of the added value exists in the list.

keys() Tuple[str, ...][source]

Get all element names.

Returns

A tuple containing all elements names.