diff options
author | Maxqia <contrib@maxqia.com> | 2016-05-02 17:06:17 -0700 |
---|---|---|
committer | Maxqia <contrib@maxqia.com> | 2016-05-03 18:59:30 -0700 |
commit | 56e53c929777a0a47d9e702219dbab4326c63010 (patch) | |
tree | 7222aa5b7bfde71d23b6332363ae9df23ba7dc4e /searx | |
parent | dcc8f996d429e3467f9dab27ed072737e919c2e8 (diff) | |
download | searxng-56e53c929777a0a47d9e702219dbab4326c63010.tar.gz searxng-56e53c929777a0a47d9e702219dbab4326c63010.zip |
[fix] currency_convert: make unit tests pass
also make regex more efficent and normalize 's'es
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/currency_convert.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index bdcd8f711..b0ffb490a 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -9,13 +9,13 @@ categories = [] url = 'https://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X' weight = 100 -parser_re = re.compile(u'.*?(\d+(?:\.\d+)?) ([^.0-9].+) (in|to) ([^\.]+)\W*$', re.I) # noqa +parser_re = re.compile(u'.*?(\d+(?:\.\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I) # noqa db = 1 def normalize_name(name): - name = name.lower().replace('-', ' ') + name = name.lower().replace('-', ' ').rstrip('s') name = re.sub(' +', ' ', name) return unicodedata.normalize('NFKD', name).lower() @@ -40,7 +40,7 @@ def request(query, params): # wrong query return params - ammount, from_currency, none, to_currency = m.groups() + ammount, from_currency, to_currency = m.groups() ammount = float(ammount) from_currency = name_to_iso4217(from_currency.strip()) to_currency = name_to_iso4217(to_currency.strip()) |