prga.util module

Utility classes and functions.

class prga.util.Enum

Bases: enum.IntEnum

IntEnum enhanced with auto-generated test methods and a few other helpful methods.

For example:
>>> class MyEnum(Enum):
...     foo = 0
...     global_ = 1
>>> MyEnum.foo.is_foo
True
>>> MyEnum.foo.is_global_
False
>>> MyEnum.global_.is_global
True

Notes

If any of the enum values has a trailing underscore, you may omit the trailing underscore

case(*args, **kwargs)

Use this enum as a variable in a switch-case clause.

Note that default is a reserved keyword. If set, the value will be used if no matching case specified.

construct = <bound method Enum.construct of <enum 'Enum'>>
class prga.util.Object

Bases: object

Base class for all PRGA objects.

class prga.util.ReadonlyMappingProxy(m, filter_=None, cast=None, uncast=None)

Bases: collections.abc.Mapping

A read-only proxy of a Mapping implementation object.

Parameters:
  • m (Mapping) – The Mapping object to be proxied
  • filter (lambda (key, value) -> bool, default=None) – An optional filter which filters the Mapping items
  • cast (lambda (key) -> key, default=None) – An optional key caster to cast a key in this proxy to a key in the proxied mapping
  • uncast (lambda (key) -> key, default=None) – An optional key caster to cast a key in the proxied maping to a key in this proxy

A read-only proxy of a Mapping object. All read-only methods of Mapping are implemented while all mutating methods are removed.

cast
filter_

an optional filter which filters the Mapping items

m

the Mapping object to be proxied

uncast
class prga.util.ReadonlySequenceProxy(s)

Bases: collections.abc.Sequence

A read-only proxy of a Sequence object.

Parameters:s (Sequence) – The Sequence object to be proxied
s

the Sequence object to be proxied

class prga.util._InheritDocstringsMeta

Bases: abc.ABCMeta

Manually inherit docstrings from superclass. This helps Sphinx for doc generation.

prga.util.enable_stdout_logging(name, level=20, verbose=False)
prga.util.uno(*args)

Return the first non- None value of the arguments

Parameters:*args – Variable positional arguments
Returns:The first non-None value or None