.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

 get_params (self, search_query, engine_category)
 
 get_default_tests (self)
 
- Public Member Functions inherited from searx.search.processors.online.OnlineProcessor
 initialize (self)
 
 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 55 of file online_currency.py.

55 def get_default_tests(self):
56 tests = {}
57
58 tests['currency'] = {
59 'matrix': {'query': '1337 usd in rmb'},
60 'result_container': ['has_answer'],
61 }
62
63 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 27 of file online_currency.py.

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

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:

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