otupy.core.register.Register

class Register

Bases: dict

List of registered elements

This class registers all available elements, both provided by the otupy and by Profiles. The class is meant to be instantiated internally and filled in with the elements provided by the Language Specification. Profiles may fill in with additional definitions, to make their classes and names available to the core system for encoding/deconding purposes.

Methods

add

Add a new element

clear

D.clear() -> None.

copy

D.copy() -> a shallow copy of D

fromkeys

Create a new dictionary with keys from iterable and values set to value.

get

Get element by name

getName

Get the name of a element

items

D.items() -> a set-like object providing a view on D's items

keys

D.keys() -> a set-like object providing a view on D's keys

pop

D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

popitem

Remove and return a (key, value) pair as a 2-tuple.

setdefault

Insert key with a value of default if key is not in the dictionary.

update

D.update([E, ]**F) -> None.

values

D.values() -> an object providing a view on D's values

__init__(*args, **kwargs)
add(name: str, register, identifier=None)

Add a new element

Register a new element and make it available within the system.

This method throw an Exception if the element is already registered.

Parameters:
  • name – The name used for the element.

  • register – The class that defines the element.

  • identifier – A numeric value associated to the standard by the Specification (unused).

Returns:

None

clear() None.  Remove all items from D.
copy() a shallow copy of D
classmethod fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(name: str)

Get element by name

Throws an exception if the given name does not correspond to any registered element.

Parameters:

name – The name of the element to return.

Returns:

The class corresponding to the given name.

getName(register)

Get the name of a element

Given a class element, this method returns its name (the name it was registered with. Note that the returned name include the namespace prefix.

Throws an exception if the given element is not registered.

Parameters:

register – The class element to look for.

Returns:

A string with the name of the element.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values