.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.search.processors.online_currency.OnlineCurrencyProcessor Class Reference
Inheritance diagram for searx.search.processors.online_currency.OnlineCurrencyProcessor:
Collaboration diagram for searx.search.processors.online_currency.OnlineCurrencyProcessor:

Public Member Functions

 initialize (self)
 get_params (self, search_query, engine_category)
 get_default_tests (self)
Public Member Functions inherited from searx.search.processors.online.OnlineProcessor
 search (self, query, params, result_container, start_time, timeout_limit)
Public Member Functions inherited from searx.search.processors.abstract.EngineProcessor
 __init__ (self, engine, str engine_name)
 has_initialize_function (self)
 handle_exception (self, result_container, exception_or_message, suspend=False)
 extend_container (self, result_container, start_time, search_results)
 extend_container_if_suspended (self, result_container)
 get_tests (self)

Additional Inherited Members

Public Attributes inherited from searx.search.processors.abstract.EngineProcessor
 engine = engine
 engine_name = engine_name
 logger = engines[engine_name].logger
 suspended_status = SUSPENDED_STATUS.setdefault(key, SuspendedStatus())
Static Public Attributes inherited from searx.search.processors.online.OnlineProcessor
str engine_type = 'online'
Protected Member Functions inherited from searx.search.processors.online.OnlineProcessor
 _send_http_request (self, params)
 _search_basic (self, query, params)
Protected Member Functions inherited from searx.search.processors.abstract.EngineProcessor
 _extend_container_basic (self, result_container, start_time, search_results)

Detailed Description

Processor class used by ``online_currency`` engines.

Definition at line 22 of file online_currency.py.

Member Function Documentation

◆ get_default_tests()

searx.search.processors.online_currency.OnlineCurrencyProcessor.get_default_tests ( self)

Reimplemented from searx.search.processors.online.OnlineProcessor.

Definition at line 59 of file online_currency.py.

59 def get_default_tests(self):
60 tests = {}
61
62 tests['currency'] = {
63 'matrix': {'query': '1337 usd in rmb'},
64 'result_container': ['has_answer'],
65 }
66
67 return tests

◆ get_params()

searx.search.processors.online_currency.OnlineCurrencyProcessor.get_params ( self,
search_query,
engine_category )
Returns a set of :ref:`request params <engine request online_currency>`
or ``None`` if search query does not match to :py:obj:`parser_re`.

Reimplemented from searx.search.processors.online.OnlineProcessor.

Definition at line 31 of file online_currency.py.

31 def get_params(self, search_query, engine_category):
32 """Returns a set of :ref:`request params <engine request online_currency>`
33 or ``None`` if search query does not match to :py:obj:`parser_re`."""
34
35 params = super().get_params(search_query, engine_category)
36 if params is None:
37 return None
38
39 m = parser_re.match(search_query.query)
40 if not m:
41 return None
42
43 amount_str, from_currency, to_currency = m.groups()
44 try:
45 amount = float(amount_str)
46 except ValueError:
47 return None
48
49 from_currency = CURRENCIES.name_to_iso4217(normalize_name(from_currency))
50 to_currency = CURRENCIES.name_to_iso4217(normalize_name(to_currency))
51
52 params['amount'] = amount
53 params['from'] = from_currency
54 params['to'] = to_currency
55 params['from_name'] = CURRENCIES.iso4217_to_name(from_currency, "en")
56 params['to_name'] = CURRENCIES.iso4217_to_name(to_currency, "en")
57 return params
58

References get_params(), and searx.search.processors.online_currency.normalize_name().

Referenced by get_params().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

searx.search.processors.online_currency.OnlineCurrencyProcessor.initialize ( self)

Reimplemented from searx.search.processors.online.OnlineProcessor.

Definition at line 27 of file online_currency.py.

27 def initialize(self):
28 CURRENCIES.init()
29 super().initialize()
30

References initialize().

Referenced by initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: