kaolin.visualize.web.naming¶
API¶
- class kaolin.visualize.web.naming.SequenceWithUniqueGlobalIds(uid_prefix='')¶
Bases:
objectA sequence of items with unique IDs, meant to be created one by one, without ability to remove item from the sequence. Each item may have a locally unique ID (e.g. “my_cat”), and will also be assigned a globally unique id (e.g. “lastname-cat13”), constructed with an optional uid_prefix and the provided identifier. Each item may be indexed by its locally unique ID, global ID or its index in the list using the [] operator. The same operator can also be used to mutate items in the sequence, but they cannot be removed.
- add(identifier, item, name_hint=None)¶
- get_unique_id(key)¶
Get the unique identifier for an item by index, identifier, or unique identifier.
- Parameters
key – Can be an int (list index), an identifier (original ID passed to add), or a unique identifier (UID returned by add).
- Returns
The unique identifier (UID) for the item.
- get_unique_id_or_raise(key)¶
- get_unique_ids_or_raise(keys)¶
- property ids¶
Return a copy of all unique identifiers.
- property items¶
Return a copy of all items.
- property unique_ids¶
Return a copy of all unique identifiers.
- property unique_ids_to_items¶
Return a copy of all unique identifiers to items.
- class kaolin.visualize.web.naming.UniqueIdGenerator(prefix=None)¶
Bases:
object- static get_unique_id(name='', prefix='kaolin')¶
- get_unique_id_local(name=None, prefix=None)¶
- reset_ids(new_ids=None)¶
- static singleton()¶
- kaolin.visualize.web.naming.generate_random_string(length=4)¶