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 tolist
.Attributes Summary
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.
Enter a context where the attributes of the parameter will be restored on exit.
L.reverse() – reverse IN PLACE
sort
([key, reverse])Represent this class as a JSON-like object.
Attributes Documentation
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
-
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.
-
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
- Raises
LookupError – If no object is found with the given name.
-
pop
([index]) → item -- remove and return item at index (default last).¶ Raises IndexError if list is empty or index is out of range.
-
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*¶
-