mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +02:00
[lint] pylint searx/search/processors files / BTW add some doc-strings
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
b1557b5443
commit
924f9afea3
6 changed files with 68 additions and 35 deletions
|
@ -1,4 +1,8 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# lint: pylint
|
||||
"""Processores for engine-type: ``online_currency``
|
||||
|
||||
"""
|
||||
|
||||
import unicodedata
|
||||
import re
|
||||
|
@ -6,32 +10,31 @@ import re
|
|||
from searx.data import CURRENCIES
|
||||
from .online import OnlineProcessor
|
||||
|
||||
|
||||
parser_re = re.compile('.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I)
|
||||
|
||||
# pylint: disable=missing-function-docstring
|
||||
|
||||
def normalize_name(name):
|
||||
name = name.lower().replace('-', ' ').rstrip('s')
|
||||
name = re.sub(' +', ' ', name)
|
||||
return unicodedata.normalize('NFKD', name).lower()
|
||||
|
||||
|
||||
def name_to_iso4217(name):
|
||||
global CURRENCIES
|
||||
global CURRENCIES # pylint: disable=global-statement
|
||||
name = normalize_name(name)
|
||||
currency = CURRENCIES['names'].get(name, [name])
|
||||
if isinstance(currency, str):
|
||||
return currency
|
||||
return currency[0]
|
||||
|
||||
|
||||
def iso4217_to_name(iso4217, language):
|
||||
global CURRENCIES
|
||||
global CURRENCIES # pylint: disable=global-statement
|
||||
return CURRENCIES['iso4217'].get(iso4217, {}).get(language, iso4217)
|
||||
|
||||
|
||||
class OnlineCurrencyProcessor(OnlineProcessor):
|
||||
|
||||
"""Processor class used by ``online_currency`` engines."""
|
||||
|
||||
engine_type = 'online_currency'
|
||||
|
||||
def get_params(self, search_query, engine_category):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue