diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2025-09-11 19:10:27 +0200 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-09-18 19:40:03 +0200 |
| commit | 8f8343dc0d78bb57215afc3e99fd9000fce6e0cf (patch) | |
| tree | 7c0aa8587ed4bc47e403b4148a308191e2d21c55 /searx/utils.py | |
| parent | 23257bddce864cfc44d64324dee36b32b1cf5248 (diff) | |
[mod] addition of various type hints / engine processors
Continuation of #5147 .. typification of the engine processors.
BTW:
- removed obsolete engine property https_support
- fixed & improved currency_convert
- engine instances can now implement a engine.setup method
[#5147] https://github.com/searxng/searxng/pull/5147
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/utils.py')
| -rw-r--r-- | searx/utils.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/searx/utils.py b/searx/utils.py index 4d826bb34..a65474c9b 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -410,38 +410,6 @@ def int_or_zero(num: list[str] | str) -> int: return convert_str_to_int(num) -def is_valid_lang(lang: str) -> tuple[bool, str, str] | None: - """Return language code and name if lang describe a language. - - Examples: - >>> is_valid_lang('zz') - None - >>> is_valid_lang('uk') - (True, 'uk', 'ukrainian') - >>> is_valid_lang(b'uk') - (True, 'uk', 'ukrainian') - >>> is_valid_lang('en') - (True, 'en', 'english') - >>> searx.utils.is_valid_lang('EspaƱol') - (True, 'es', 'spanish') - >>> searx.utils.is_valid_lang('Spanish') - (True, 'es', 'spanish') - """ - if isinstance(lang, bytes): - lang = lang.decode() - is_abbr = len(lang) == 2 - lang = lang.lower() - if is_abbr: - for l in sxng_locales: - if l[0][:2] == lang: - return (True, l[0][:2], l[3].lower()) - return None - for l in sxng_locales: - if l[1].lower() == lang or l[3].lower() == lang: - return (True, l[0][:2], l[3].lower()) - return None - - def load_module(filename: str, module_dir: str) -> types.ModuleType: modname = splitext(filename)[0] modpath = join(module_dir, filename) |