.utils package

Submodules

.utils.coll module

class IndexedDictionary[source]

Bases: Dict

append(value) int[source]
T
sphinx-autodoc can’t document typevars properly right now,

see https://github.com/agronholm/sphinx-autodoc-typehints/issues/39

A generic type for elements of an iterable.

Type

alias of TypeVar(‘T’)

flatten(_iter: Iterable[Iterable[ska_ser_skallop.utils.coll.T]]) Iterable[ska_ser_skallop.utils.coll.T][source]

.utils.device_health module

.utils.env module

class TelescopeTypeContainer(*args: Any, **kwargs: Any)[source]

Bases: object

is_type_low() bool[source]
is_type_mid() bool[source]
property is_type_set: bool
set_telescope_type_as_low()[source]
set_telescope_type_as_mid()[source]
build_in_testing() bool[source]
get_entry_point_from_env() Optional[str][source]
get_temp_dir(prefix: Optional[str] = None) str[source]

generate a path to a directory deleted at the end of the program.

Parameters

prefix – a prefix to start the name of the directory with, defaults to None

Returns

string representing the path to the directory

get_tmc_central_node_fqdn() str[source]
get_tmc_subarray_node_fqdn() str[source]
i_can_import(module_name: str)[source]
is_telescope_type_already_set() bool[source]
profile_it()[source]
set_telescope_as_low() None[source]
set_telescope_as_mid() None[source]
set_telescope_type_from_env() Literal['skalow', 'skamid'][source]
telescope_set_as_low_from_env() bool[source]
telescope_type_is_low() bool[source]
telescope_type_is_mid() bool[source]

.utils.generic_classes module

class Symbol[source]

Bases: object

abstract property enabled: bool

Whether the device is withing currently set scoped or not.

Returns

True if the device is within the scope.

.utils.nrgen module

get_id(id_pattern: str = '********-*****') str[source]

Generate a time-based unique id in virtue of the fact that subsequent requests will take place further ahead of time.

Parameters

id_pattern – the string pattern as to how the numbered id should be rendered. <prefix>pattern<suffix> ‘*’ indicates a digit from the timestamp. Note a maximum of 16 digits is allowed. Defaults to ‘****-*’. Note digits must be seperated by only one dash at a time.

Returns

the id rendered according to the requested pattern

get_int_id() int[source]

.utils.singleton module

This module provides a Singleton metaclass.

class Memo(**kwargs)[source]

Bases: object

Singleton class that will store any given variables across multiple class instances.

To store a value you can either provide it as an argument upon instantiation or with the set method. To retrieve a value you use a get method (returns None if value doesn’t exist)

e.g.:

memo = Memo(foo='bar')
assert memo.get('foo') == 'bar'

# or alternatively
memo.reset() # equal to creating a new instance with all values resetted.
memo.set(foo='bar')
assert memo.get('foo') == 'bar'
get(key: Any) Union[None, Any][source]

Return a stored value (if exists) for a given key.

Parameters

key – The key or id of the expected variable

Returns

The value of the key if exists, otherwise None

reset() None[source]

Clears all stored values to None

set(**kwargs) None[source]

Store a (or update) a set of given key/value pairs as given by the kwargs.

class Singleton[source]

Bases: type

A metaclass that ensures that only one instance exists. If you try to create an instance of a class based on this metaclass, and an instance has been created already, then the existing instance is returned.

Usage:

class TangoBridge(metaclass=Singleton)
    ....

Module contents