woob.tools.value

class ValuesDict(*values)[source]

Bases: OrderedDict

Ordered dictionarry which can take values in constructor.

>>> ValuesDict(Value('a', label='Test'), ValueInt('b', label='Test2'))
class Value(*args, **kwargs)[source]

Bases: object

Value.

Parameters
  • label (str) – human readable description of a value

  • required (bool) – if True, the backend can’t load if the key isn’t found in its configuration

  • default – an optional default value, used when the key is not in config. If there is no default value and the key is not found in configuration, the required parameter is implicitly set

  • masked (bool) – if True, the value is masked. It is useful for applications to know if this key is a password

  • regexp (str) – if specified, on load the specified value is checked against this regexp, and an error is raised if it doesn’t match

  • choices ((list,dict)) – if this parameter is set, the value must be in the list

  • aliases (dict) – mapping of old choices values that should be accepted but not presented

  • tiny (bool) – the value of choices can be entered by an user (as they are small)

  • transient (bool) – this value is not persistent (asked only if needed)

static get_normalized_regexp(regexp)[source]

Return normalized regexp adding missing anchors

show_value(v)[source]
check_valid(v)[source]

Check if the given value is valid.

Raises

ValueError

load(domain, v, requests)[source]

Load value.

Parameters
  • domain (str) – what is the domain of this value

  • v – value to load

  • requests (woob.core.requests.Requests) – list of woob requests

set(v)[source]

Set a value.

dump()[source]

Dump value to be stored.

get()[source]

Get the value.

class ValueBackendPassword(*args, **kwargs)[source]

Bases: Value

load(domain, password, requests)[source]

Load value.

Parameters
  • domain (str) – what is the domain of this value

  • v – value to load

  • requests (woob.core.requests.Requests) – list of woob requests

check_valid(passwd)[source]

Check if the given value is valid.

Raises

ValueError

set(passwd)[source]

Set a value.

dump()[source]

Dump value to be stored.

get()[source]

Get the value.

class ValueInt(*args, **kwargs)[source]

Bases: Value

get()[source]

Get the value.

class ValueFloat(*args, **kwargs)[source]

Bases: Value

check_valid(v)[source]

Check if the given value is valid.

Raises

ValueError

get()[source]

Get the value.

class ValueBool(*args, **kwargs)[source]

Bases: Value

check_valid(v)[source]

Check if the given value is valid.

Raises

ValueError

get()[source]

Get the value.