diff options
author | JPFrancoia <jeanpatrick.francoia@gmail.com> | 2019-12-25 11:06:01 +0100 |
---|---|---|
committer | JPFrancoia <jeanpatrick.francoia@gmail.com> | 2019-12-25 11:06:01 +0100 |
commit | 3435c5b357e7bd0bfc1ea1720230f534b14a5c15 (patch) | |
tree | efe0d7cebcaafb5560ff5b614e8ab0cd4f09f855 /tpblite/models/utils.py | |
parent | ec4f40de81d75d54764ab16915aefd082585ea4a (diff) | |
download | tpb-lite-3435c5b357e7bd0bfc1ea1720230f534b14a5c15.tar.gz tpb-lite-3435c5b357e7bd0bfc1ea1720230f534b14a5c15.tar.bz2 tpb-lite-3435c5b357e7bd0bfc1ea1720230f534b14a5c15.zip |
Renaming QueryParser from_browse and from_search methods to browse and
search. Adding type hinting for these two methods.
Diffstat (limited to 'tpblite/models/utils.py')
-rw-r--r-- | tpblite/models/utils.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tpblite/models/utils.py b/tpblite/models/utils.py index 1d5bda6..c6b6248 100644 --- a/tpblite/models/utils.py +++ b/tpblite/models/utils.py @@ -1,9 +1,12 @@ -from typing import Tuple +from typing import Tuple, TypeVar import random from urllib.request import Request, urlopen import urllib.error from purl import URL as pURL +# https://github.com/python/typing/issues/58#issuecomment-326240794 +T = TypeVar("T", bound="QueryParser") + class QueryParser: """Query object capable of getting html response given a search query and other @@ -27,14 +30,14 @@ class QueryParser: ) @classmethod - def from_search( + def search( cls, query: str, base_url: str, page: int, order: int, category: int - ): + ) -> T: segments = ("search", query, str(page), str(order), str(category)) return cls(base_url, segments) @classmethod - def from_browse(cls, base_url: str, category: int, page: int, order: int): + def browse(cls, base_url: str, category: int, page: int, order: int) -> T: segments = ("browse", str(category), str(page), str(order), "0") return cls(base_url, segments) |