diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2021-12-27 09:26:22 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-12-27 09:26:22 +0100 |
commit | 3d96a9839a12649874b6d4cf9466bd3616b0a03c (patch) | |
tree | e7d54d1e345b1e792d538ddc250f4827bb2fd9b9 /searx/settings_defaults.py | |
parent | fcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c (diff) | |
download | searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.tar.gz searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.zip |
[format.python] initial formatting of the python code
This patch was generated by black [1]::
make format.python
[1] https://github.com/psf/black
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/settings_defaults.py')
-rw-r--r-- | searx/settings_defaults.py | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index db020db7d..9c4711bfc 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -53,29 +53,24 @@ SEARX_ENVIRON_VARIABLES = { } - class SettingsValue: - """Check and update a setting value - """ - - def __init__(self, - type_definition: typing.Union[None, typing.Any, typing.Tuple[typing.Any]]=None, - default: typing.Any=None, - environ_name: str=None): + """Check and update a setting value""" + + def __init__( + self, + type_definition: typing.Union[None, typing.Any, typing.Tuple[typing.Any]] = None, + default: typing.Any = None, + environ_name: str = None, + ): self.type_definition = ( - type_definition - if type_definition is None or isinstance(type_definition, tuple) - else (type_definition,) + type_definition if type_definition is None or isinstance(type_definition, tuple) else (type_definition,) ) self.default = default self.environ_name = environ_name @property def type_definition_repr(self): - types_str = [ - t.__name__ if isinstance(t, type) else repr(t) - for t in self.type_definition - ] + types_str = [t.__name__ if isinstance(t, type) else repr(t) for t in self.type_definition] return ', '.join(types_str) def check_type_definition(self, value: typing.Any) -> None: @@ -83,9 +78,7 @@ class SettingsValue: return type_list = tuple(t for t in self.type_definition if isinstance(t, type)) if not isinstance(value, type_list): - raise ValueError( - 'The value has to be one of these types/values: {}'.format( - self.type_definition_repr)) + raise ValueError('The value has to be one of these types/values: {}'.format(self.type_definition_repr)) def __call__(self, value: typing.Any) -> typing.Any: if value == _UNDEFINED: @@ -101,8 +94,7 @@ class SettingsValue: class SettingSublistValue(SettingsValue): - """Check the value is a sublist of type definition. - """ + """Check the value is a sublist of type definition.""" def check_type_definition(self, value: typing.Any) -> typing.Any: if not isinstance(value, list): @@ -111,9 +103,9 @@ class SettingSublistValue(SettingsValue): if not item in self.type_definition[0]: raise ValueError('{} not in {}'.format(item, self.type_definition)) + class SettingsDirectoryValue(SettingsValue): - """Check and update a setting value that is a directory path - """ + """Check and update a setting value that is a directory path""" def check_type_definition(self, value: typing.Any) -> typing.Any: super().check_type_definition(value) @@ -159,7 +151,7 @@ SCHEMA = { 'wiki_url': SettingsValue(str, 'https://github.com/searxng/searxng/wiki'), }, 'search': { - 'safe_search': SettingsValue((0,1,2), 0), + 'safe_search': SettingsValue((0, 1, 2), 0), 'autocomplete': SettingsValue(str, ''), 'default_lang': SettingsValue(tuple(LANGUAGE_CODES + ['']), ''), 'languages': SettingSublistValue(LANGUAGE_CODES, LANGUAGE_CODES), @@ -168,7 +160,7 @@ SCHEMA = { 'formats': SettingsValue(list, OUTPUT_FORMATS), }, 'server': { - 'port': SettingsValue((int,str), 8888, 'SEARXNG_PORT'), + 'port': SettingsValue((int, str), 8888, 'SEARXNG_PORT'), 'bind_address': SettingsValue(str, '127.0.0.1', 'SEARXNG_BIND_ADDRESS'), 'secret_key': SettingsValue(str, environ_name='SEARXNG_SECRET'), 'base_url': SettingsValue((False, str), False), @@ -213,8 +205,7 @@ SCHEMA = { # Tor configuration 'using_tor_proxy': SettingsValue(bool, False), 'extra_proxy_timeout': SettingsValue(int, 0), - 'networks': { - }, + 'networks': {}, }, 'plugins': SettingsValue(list, []), 'enabled_plugins': SettingsValue((None, list), None), @@ -222,10 +213,10 @@ SCHEMA = { 'off_when_debug': SettingsValue(bool, True), }, 'engines': SettingsValue(list, []), - 'doi_resolvers': { - }, + 'doi_resolvers': {}, } + def settings_set_defaults(settings): # compatibility with searx variables for searx, searxng in SEARX_ENVIRON_VARIABLES.items(): |