boss.configuration

Classes

Document

dict() -> new empty dictionary

WorkerConfigurationDocument

dict() -> new empty dictionary

Functions

_heroref_arguments(classname) → frozenset[str]

Return the argument names in which a HERO class receives HERORef values instead of RemoteHEROs.

_resolve_references(value, realm, *[, as_ref]) → object

Replace $name strings at any depth with remote HEROs or, with as_ref, with HERORef values.

Module Contents

boss.configuration._heroref_arguments(classname: str) → frozenset[str][source]

Return the argument names in which a HERO class receives HERORef values instead of RemoteHEROs.

The names are read from the class attribute _boss_heroref_arguments of the class given by classname. With wrap_target set, this is the unwrapped class. Names that match no argument are ignored.

Parameters:

classname – dotted name of the class to be built

Returns:

The argument names, empty if the class has no _boss_heroref_arguments.

Raises:

TypeError – if _boss_heroref_arguments is a single string or contains a name that is not a string.

boss.configuration._resolve_references(value: object, realm: str, *, as_ref: bool = False) → object[source]

Replace $name strings at any depth with remote HEROs or, with as_ref, with HERORef values.

A leading $$ is an escape: one $ is stripped and the string is passed on literally. Dict keys are not resolved. Containers are rebuilt, the input is not modified.

Parameters:
  • value – argument value, possibly a nested dict, list or tuple

  • realm – realm in which the referenced HEROs are looked up or which the HERORef values carry

  • as_ref – build HERORef(name, realm) instead of looking up a RemoteHERO

Returns:

The value with all references resolved.

class boss.configuration.Document[source]

Bases: dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

classmethod parse_string(s: str)[source]

Parse a document in JSON format from a string.

Parameters:

s – string containing the JSON representation of the config

classmethod parse_url(url: str)[source]

Parse a document in JSON format from a URL.

Parameters:

url – any URL supported by urllib (e.g. file://local.json or https://user:pass@couch.db/database/my_doc)

class boss.configuration.WorkerConfigurationDocument[source]

Bases: Document

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

datasource_config()[source]
generate_tags(boss_name)[source]

Add boss/configuration specific tags to the HERO.

build_hero_for_worker(boss_name: str, worker_object, realm='heros')[source]