.oO SearXNG Developer Documentation Oo.
|
Classes | |
class | Config |
class | FALSE |
class | SchemaIssue |
Functions | |
toml_load (file_name) | |
value (str name, dict data_dict) | |
typing.Tuple[bool, list] | validate (typing.Dict schema_dict, typing.Dict data_dict, typing.Dict[str, str] deprecated) |
typing.Tuple[bool, typing.List] | _validate (typing.List names, typing.List issue_list, typing.Dict schema_dict, typing.Dict data_dict, typing.Dict[str, str] deprecated) |
dict_deepupdate (dict base_dict, dict upd_dict, names=None) | |
Variables | |
list | __all__ = ['Config', 'UNSET', 'SchemaIssue'] |
log = logging.getLogger(__name__) | |
UNSET = FALSE('<UNSET>') | |
Configuration class :py:class:`Config` with deep-update, schema validation and deprecated names. The :py:class:`Config` class implements a configuration that is based on structured dictionaries. The configuration schema is defined in a dictionary structure and the configuration data is given in a dictionary structure.
|
protected |
Definition at line 257 of file config.py.
References searx.botdetection.config._validate(), and searx.botdetection.config.value().
Referenced by searx.botdetection.config._validate(), and searx.botdetection.config.validate().
searx.botdetection.config.dict_deepupdate | ( | dict | base_dict, |
dict | upd_dict, | ||
names = None ) |
Deep-update of dictionary in ``base_dict`` by dictionary in ``upd_dict``. For each ``upd_key`` & ``upd_val`` pair in ``upd_dict``: 0. If types of ``base_dict[upd_key]`` and ``upd_val`` do not match raise a :py:obj:`TypeError`. 1. If ``base_dict[upd_key]`` is a dict: recursively deep-update it by ``upd_val``. 2. If ``base_dict[upd_key]`` not exist: set ``base_dict[upd_key]`` from a (deep-) copy of ``upd_val``. 3. If ``upd_val`` is a list, extend list in ``base_dict[upd_key]`` by the list in ``upd_val``. 4. If ``upd_val`` is a set, update set in ``base_dict[upd_key]`` by set in ``upd_val``.
Definition at line 301 of file config.py.
References searx.botdetection.config.dict_deepupdate().
Referenced by searx.botdetection.config.dict_deepupdate(), and searx.botdetection.config.Config.update().
searx.botdetection.config.toml_load | ( | file_name | ) |
Definition at line 175 of file config.py.
Referenced by searx.botdetection.config.Config.from_toml().
typing.Tuple[bool, list] searx.botdetection.config.validate | ( | typing.Dict | schema_dict, |
typing.Dict | data_dict, | ||
typing.Dict[str, str] | deprecated ) |
Deep validation of dictionary in ``data_dict`` against dictionary in ``schema_dict``. Argument deprecated is a dictionary that maps deprecated configuration names to a messages:: deprecated = { "foo.bar" : "config 'foo.bar' is deprecated, use 'bar.foo'", "..." : "..." } The function returns a python tuple ``(is_valid, issue_list)``: ``is_valid``: A bool value indicating ``data_dict`` is valid or not. ``issue_list``: A list of messages (:py:obj:`SchemaIssue`) from the validation:: [schema warn] data_dict: deprecated 'fontlib.foo': <DEPRECATED['foo.bar']> [schema invalid] data_dict: key unknown 'fontlib.foo' [schema invalid] data_dict: type mismatch 'fontlib.foo': expected ..., is ... If ``schema_dict`` or ``data_dict`` is not a dictionary type a :py:obj:`SchemaIssue` is raised.
Definition at line 216 of file config.py.
References searx.botdetection.config._validate().
searx.botdetection.config.value | ( | str | name, |
dict | data_dict ) |
Returns the value to which ``name`` points in the ``dat_dict``. .. code: python >>> data_dict = { "foo": {"bar": 1 }, "bar": {"foo": 2 }, "foobar": [1, 2, 3], } >>> value('foobar', data_dict) [1, 2, 3] >>> value('foo.bar', data_dict) 1 >>> value('foo.bar.xxx', data_dict) <UNSET>
Definition at line 188 of file config.py.
Referenced by searx.botdetection.config.Config._get_parent_dict(), searx.botdetection.config._validate(), and searx.botdetection.config.Config.default().
|
private |
searx.botdetection.config.log = logging.getLogger(__name__) |