summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-11-14 13:23:44 +0100
committerGitHub <noreply@github.com>2020-11-14 13:23:44 +0100
commit46b454277f70cb504a1276286e07048b8a5651bf (patch)
tree0d4d536500e98c818e3f6ee010b613faf7ce0554 /searx
parentebed1461bc4b635b6dde5d99e53dada6711a6d7a (diff)
parent8fc74d0d7b51014a24c9d2dc9442434d91c4e711 (diff)
downloadsearxng-46b454277f70cb504a1276286e07048b8a5651bf.tar.gz
searxng-46b454277f70cb504a1276286e07048b8a5651bf.zip
Merge pull request #2309 from dalf/mod_search_repr
[mod] searx.search: EngineRef, SearchQuery: add __repr__ and __eq__ methods
Diffstat (limited to 'searx')
-rw-r--r--searx/search.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/searx/search.py b/searx/search.py
index cd195825a..04c6b2885 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -57,8 +57,11 @@ class EngineRef:
self.category = category
self.from_bang = from_bang
- def __str__(self):
- return "(" + self.name + "," + self.category + "," + str(self.from_bang) + ")"
+ def __repr__(self):
+ return "EngineRef({!r}, {!r}, {!r})".format(self.name, self.category, self.from_bang)
+
+ def __eq__(self, other):
+ return self.name == other.name and self.category == other.category and self.from_bang == other.from_bang
class SearchQuery:
@@ -87,8 +90,21 @@ class SearchQuery:
self.timeout_limit = timeout_limit
self.external_bang = external_bang
- def __str__(self):
- return self.query + ";" + str(self.engineref_list)
+ def __repr__(self):
+ return "SearchQuery({!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})".\
+ format(self.query, self.engineref_list, self.categories, self.lang, self.safesearch,
+ self.pageno, self.time_range, self.timeout_limit, self.external_bang)
+
+ def __eq__(self, other):
+ return self.query == other.query\
+ and self.engineref_list == other.engineref_list\
+ and self.categories == self.categories\
+ and self.lang == other.lang\
+ and self.safesearch == other.safesearch\
+ and self.pageno == other.pageno\
+ and self.time_range == other.time_range\
+ and self.timeout_limit == other.timeout_limit\
+ and self.external_bang == other.external_bang
def send_http_request(engine, request_params):