59 def get_params(self, search_query:
"SearchQuery", engine_category: str) -> OnlineCurrenciesParams |
None:
60 """Returns a dictionary with the :ref:`request params <engine request
61 online_currency>` (:py:obj:`OnlineCurrenciesParams`). ``None`` is
62 returned if the search query does not match :py:obj:`search_syntax`."""
64 online_params: OnlineParams |
None = super().
get_params(search_query, engine_category)
66 if online_params
is None:
68 m = search_syntax.match(search_query.query)
72 amount_str, from_currency, to_currency = m.groups()
74 amount = float(amount_str)
79 if from_currency ==
"$":
80 from_currency =
"$ us"
82 if to_currency ==
"$":
85 from_iso4217 = from_currency
86 if not CURRENCIES.is_iso4217(from_iso4217):
87 from_iso4217 = CURRENCIES.name_to_iso4217(
_normalize_name(from_currency))
89 to_iso4217 = to_currency
90 if not CURRENCIES.is_iso4217(to_iso4217):
93 if from_iso4217
is None or to_iso4217
is None:
96 ui_locale = flask_babel.get_locale()
or babel.Locale.parse(
"en")
97 from_name: str = CURRENCIES.iso4217_to_name(
98 from_iso4217, ui_locale.language
100 to_name: str = CURRENCIES.iso4217_to_name(
101 to_iso4217, ui_locale.language
104 params: OnlineCurrenciesParams = {
107 "from_iso4217": from_iso4217,
108 "to_iso4217": to_iso4217,
109 "from_name": from_name,