argopy.utilities.Registry#

class Registry(initlist=None, name: str = 'unnamed', dtype='str', invalid='raise')[source]#

A list manager can that validate item type

Examples

You can commit new entry to the registry, one by one:

>>> R = Registry(name='file')
>>> R.commit('meds/4901105/profiles/D4901105_017.nc')
>>> R.commit('aoml/1900046/profiles/D1900046_179.nc')

Or with a list:

>>> R = Registry(name='My floats', dtype='wmo')
>>> R.commit([2901746, 4902252])

And also at instantiation time (name and dtype are optional):

>>> R = Registry([2901746, 4902252], name='My floats', dtype=float_wmo)

Registry can be used like a list.

It is iterable:

>>> for wmo in R:
>>>     print(wmo)

It has a len property:

>>> len(R)

It can be checked for values:

>>> 4902252 in R

You can also remove items from the registry, again one by one or with a list:

>>> R.remove('2901746')
__init__(initlist=None, name: str = 'unnamed', dtype='str', invalid='raise')[source]#

Create a registry, i.e. a controlled list

Parameters
  • initlist (list, optional) – List of values to register

  • name (str, default: 'unnamed') – Name of the Registry

  • dtype (str or dtype, default: str) – Data type of registry content. Supported values are: ‘str’, ‘wmo’, float_wmo

  • invalid (str, default: 'raise') – Define what do to when a new item is not valid. Can be ‘raise’ or ‘ignore’

Methods

__init__([initlist, name, dtype, invalid])

Create a registry, i.e. a controlled list.

append(value)

R.append(value) -- append value to the end of the registry

clear()

commit(values)

R.commit(values) -- append values to the end of the registry if not already in

copy()

Return a shallow copy of the registry

count(value)

extend(other)

R.extend(iterable) -- extend registry by appending elements from the iterable

index(value, [start, [stop]])

Raises ValueError if the value is not present.

insert(index, value)

R.insert(index, value) -- insert value before index.

pop([index])

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

remove(values)

R.remove(valueS) -- remove first occurrence of values.

reverse()

S.reverse() -- reverse IN PLACE

sort(*args, **kwds)