prga.util module¶
Utility classes and functions.
-
class
prga.util.Enum¶ Bases:
enum.IntEnumIntEnumenhanced 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
defaultis 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:
objectBase class for all PRGA objects.
-
class
prga.util.ReadonlyMappingProxy(m, filter_=None, cast=None, uncast=None)¶ Bases:
collections.abc.MappingA read-only proxy of a
Mappingimplementation object.Parameters: - m (
Mapping) – TheMappingobject to be proxied - filter (
lambda (key, value) -> bool, default=None) – An optional filter which filters theMappingitems - 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
Mappingobject. All read-only methods ofMappingare implemented while all mutating methods are removed.-
cast¶
-
filter_¶ an optional filter which filters the
Mappingitems
-
m¶ the
Mappingobject to be proxied
-
uncast¶
- m (
-
class
prga.util.ReadonlySequenceProxy(s)¶ Bases:
collections.abc.SequenceA read-only proxy of a
Sequenceobject.Parameters: s ( Sequence) – TheSequenceobject to be proxied-
s¶ the
Sequenceobject to be proxied
-
-
class
prga.util._InheritDocstringsMeta¶ Bases:
abc.ABCMetaManually 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- Nonevalue or None