diff options
author | Alexandre Flament <alex@al-f.net> | 2020-09-22 16:22:22 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-09-22 18:59:51 +0200 |
commit | 2929495112e9869af24986b27066163572bc558a (patch) | |
tree | 988e17588dd5beb96a34e44ba7220828f1253b2e /searx/query.py | |
parent | 2dbc0de0cd000459ebfdb3d015be8684e737e95c (diff) | |
download | searxng-2929495112e9869af24986b27066163572bc558a.tar.gz searxng-2929495112e9869af24986b27066163572bc558a.zip |
[mod] add searx.search.EngineRef
was previously a Dict with two or three keys: name, category, from_bang
make clear that this is a engine reference (see tests/unit/test_search.py for example)
all variables using this class are renamed accordingly.
Diffstat (limited to 'searx/query.py')
-rw-r--r-- | searx/query.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/searx/query.py b/searx/query.py index 9e2af0c45..2d5a72bcb 100644 --- a/searx/query.py +++ b/searx/query.py @@ -20,9 +20,8 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. import re from searx.languages import language_codes -from searx.engines import ( - categories, engines, engine_shortcuts -) +from searx.engines import categories, engines, engine_shortcuts +from searx.search import EngineRef VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$') @@ -40,7 +39,7 @@ class RawTextQuery: self.disabled_engines = disabled_engines self.query_parts = [] - self.engines = [] + self.enginerefs = [] self.languages = [] self.timeout_limit = None self.external_bang = None @@ -135,26 +134,21 @@ class RawTextQuery: parse_next = True engine_name = engine_shortcuts[prefix] if engine_name in engines: - self.engines.append({'category': 'none', - 'name': engine_name, - 'from_bang': True}) + self.enginerefs.append(EngineRef(engine_name, 'none', True)) # check if prefix is equal with engine name elif prefix in engines: parse_next = True - self.engines.append({'category': 'none', - 'name': prefix, - 'from_bang': True}) + self.enginerefs.append(EngineRef(prefix, 'none', True)) # check if prefix is equal with categorie name elif prefix in categories: # using all engines for that search, which # are declared under that categorie name parse_next = True - self.engines.extend({'category': prefix, - 'name': engine.name} - for engine in categories[prefix] - if (engine.name, prefix) not in self.disabled_engines) + self.enginerefs.extend(EngineRef(engine.name, prefix) + for engine in categories[prefix] + if (engine.name, prefix) not in self.disabled_engines) if query_part[0] == '!': self.specific = True |