From 8f8343dc0d78bb57215afc3e99fd9000fce6e0cf Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 11 Sep 2025 19:10:27 +0200 Subject: [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 --- searx/utils.py | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'searx/utils.py') 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) -- cgit v1.2.3