Config

class Config.Config[source]
load_file(f)[source]

Reads the configuration parameters from a file and adds them to the inner set of parameters :type f: string

parse_cmd_args(args)[source]
Parameters:args (list[str]|tuple[str]) –
add_line(key, value)[source]

Adds one specific configuration (key,value) pair to the inner set of parameters :type key: str :type value: str

has(key)[source]

Returns whether the given key is present in the inner set of parameters :type key: string :rtype: boolean :returns True if and only if the given key is in the inner set of parameters

is_typed(key)[source]
Return type:boolean

:returns True if and only if the value of the given key has a specified data type

is_true(key, default=False)[source]
Parameters:
  • key (str) –
  • default (bool) –
Returns:

bool(value) if it is set or default

Return type:

bool

is_of_type(key, types)[source]
Parameters:
  • key (str) –
  • types (type|tuple[type]) – for isinstance() check
Returns:

whether is_typed(key) is True and isinstance(value, types) is True

Return type:

bool

get_of_type(key, types, default=None)[source]
Parameters:
  • key (str) –
  • types (type|list[type]|T) – for isinstance() check
  • default (T|None) –
Returns:

if is_of_type(key, types) is True, returns the value, otherwise default

Return type:

T

set(key, value)[source]
update(dikt)[source]
value(key, default, index=None, list_join_str=', ')[source]
Return type:str | T
typed_value(key, default=None, index=None)[source]
Return type:T | object
opt_typed_value(key, default=None)[source]
Parameters:
  • key (str) –
  • default (T|None) –
Return type:

T|object|str|None

int(key, default, index=0)[source]

Parses the value of the given key as integer, returning default if not existent :type key: str :type default: T :type index: int :rtype: int | T

bool(key, default, index=0)[source]

Parses the value of the given key as boolean, returning default if not existent :type key: str :type default: T :type index: bool :rtype: bool | T

bool_or_other(key, default, index=0)[source]
float(key, default, index=0)[source]

Parses the value of the given key as float, returning default if not existent :type key: str :type default: T :type index: int :rtype: float | T

list(key, default=None)[source]
Return type:list[str] | T
int_list(key, default=None)[source]
Return type:list[int] | T
float_list(key, default=None)[source]
Return type:list[float] | T
int_pair(key, default=None)[source]
Config.get_global_config()[source]
Return type:Config