Registry

class minkit.Registry(*args, **kwargs)[source]

Bases: list

Extension of list to hold information used in minkit. It represents a collection of objects with the attribute name, providing a unique identifier (each object is assumed to be identified by its name). Any attempt to add a new element to the registry with the same name as one already existing will skip the process, as long as the two objects are the same. If they are not, then an error is raised. Constructor is directly forwarded to list.

Attributes Summary

names

Names in the current registry.

Methods Summary

append(el)

Append a new element to the registry.

clear()

copy([contained_type])

Create a copy of this instance.

count(value)

extend(iterable)

from_json_object(obj)

Build the parameter from a JSON object (a dictionary).

get(name)

Return the object with name name in this registry.

index(name)

Get the position in the registry of the parameter with the given name.

insert(i, p)

Insert an object before index i.

pop([index])

Raises IndexError if list is empty or index is out of range.

reduce(names)

Create a new Registry object keeping only the given names.

remove(value)

Raises ValueError if the value is not present.

restoring_state()

Enter a context where the attributes of the parameter will be restored on exit.

reverse

L.reverse() – reverse IN PLACE

sort([key, reverse])

to_json_object()

Represent this class as a JSON-like object.

Attributes Documentation

names

Names in the current registry.

Type

list(str)

Methods Documentation

append(el)[source]

Append a new element to the registry.

Parameters

el (object) – new element to add.

clear() → None -- remove all items from L
copy(contained_type='parameter')[source]

Create a copy of this instance.

Returns

Copy of this instance.

Return type

Registry

count(value) → integer -- return number of occurrences of value
extend(iterable) → None -- extend list by appending elements from the iterable
classmethod from_json_object(obj)[source]

Build the parameter from a JSON object (a dictionary). This is meant to be used together with the json module.

Parameters

obj (dict) – object to use to construct the class.

Returns

parameter created from the JSON object.

Return type

Registry

get(name)[source]

Return the object with name name in this registry.

Parameters

name (str) – name of the object.

Returns

object with the specified name.

Raises

LookupError – If no object is found with the given name.

index(name)[source]

Get the position in the registry of the parameter with the given name.

Parameters

name (str) – name of the parameter.

Returns

position.

Return type

int

Raises

LookupError – If no object is found with the given name.

insert(i, p)[source]

Insert an object before index i.

Parameters
  • i (int) – index where to insert the object.

  • p (object) – object to insert.

pop([index]) → item -- remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

reduce(names)[source]

Create a new Registry object keeping only the given names.

Parameters

names (tuple(str)) – names

Returns

new registry keeping only the provided names.

Rype

Registry

remove(value) → None -- remove first occurrence of value.

Raises ValueError if the value is not present.

restoring_state()[source]

Enter a context where the attributes of the parameter will be restored on exit.

reverse()

L.reverse() – reverse IN PLACE

sort(key=None, reverse=False) → None -- stable sort *IN PLACE*
to_json_object()[source]

Represent this class as a JSON-like object.

Returns

this class as a JSON-like object.

Return type

dict