.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)
 

Static Public Attributes

str engine_type = 'online_currency'
 
- Static Public Attributes inherited from searx.search.processors.online.OnlineProcessor
str engine_type = 'online'
 

Additional Inherited Members

- Public Attributes inherited from searx.search.processors.online.OnlineProcessor
 engine_name
 
 engine
 
- 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())
 
- 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 33 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 65 of file online_currency.py.

65 def get_default_tests(self):
66 tests = {}
67
68 tests['currency'] = {
69 'matrix': {'query': '1337 usd in rmb'},
70 'result_container': ['has_answer'],
71 }
72
73 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 38 of file online_currency.py.

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

References searx.search.processors.online_currency.OnlineCurrencyProcessor.get_params(), searx.search.processors.online_currency.iso4217_to_name(), and searx.search.processors.online_currency.name_to_iso4217().

Referenced by searx.search.processors.online_currency.OnlineCurrencyProcessor.get_params().

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

Member Data Documentation

◆ engine_type

str searx.search.processors.online_currency.OnlineCurrencyProcessor.engine_type = 'online_currency'
static

Definition at line 36 of file online_currency.py.


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