woob.tools.value

class ValuesDict(*values)[source]

Bases: OrderedDict

Ordered dictionary which can take values in constructor.

>>> ValuesDict(Value('a', label='Test'), ValueInt('b', label='Test2'))
with_values(*values)[source]

Get a copy of the object, with new values.

Parameters:

values (Value) – The values to set.

Return type:

TypeVar(ValuesDictType, bound= ValuesDict)

Returns:

The new values dictionary.

with_values_from(other)[source]

Get a copy of the object, with overrides from another values dictionary.

Values from the other dictionary will override values from the current dictionary.

Parameters:

other (ValuesDict) – the other dictionary to take values from.

Return type:

TypeVar(ValuesDictType, bound= ValuesDict)

Returns:

The new values dictionary.

without_values(*value_names)[source]

Get a copy of the object, without values with the given names.

This method will ignore value names that aren’t present in the original dictionary.

Parameters:

value_names (str) – The name of the values to remove.

Return type:

TypeVar(ValuesDictType, bound= ValuesDict)

Returns:

The new values dictionary.

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.