Compare commits

..

No commits in common. "main" and "v0.1.3" have entirely different histories.
main ... v0.1.3

6 changed files with 20 additions and 26 deletions

View File

@ -1,5 +1,5 @@
"""# Common HTTP/REST clients interface"""
"""# Common HTTP/REST clients interface
"""
import urllib.parse
import abc
@ -11,10 +11,6 @@ import bs4
import lxml.html
import requests
from ._version import __version__
__all__ = ['__version__']
logger = logging.getLogger(__name__)
@ -45,9 +41,7 @@ class AbstractClient(abc.ABC):
def fetch(self, url: str, **kwargs) -> requests.Response:
r = self._fetch(url, **kwargs)
if r.status_code in {301,302,303}:
msg = (
f'Redirection: {r.request.method} {url} -> GET {r.headers["Location"]}'
)
msg = f'Redirection: {r.request.method} {url} -> GET {r.headers["Location"]}'
raise Exception(msg)
r.raise_for_status()
return r
@ -57,9 +51,7 @@ class AbstractClient(abc.ABC):
kwargs.setdefault('allow_redirects', True)
url_parsed = urllib.parse.urlparse(url)
origin_url = url_parsed._replace(
path='', params='', query='', fragment=''
).geturl()
origin_url = url_parsed._replace(path='',params='',query='',fragment='').geturl()
kwargs.setdefault('headers', {}).setdefault('Origin', origin_url)
kwargs.setdefault('headers', {}).setdefault('Alt-Used', url_parsed.hostname)

View File

@ -1 +1 @@
__version__ = '0.1.6'
__version__ = '0.1.3'

View File

@ -15,7 +15,6 @@ DEFAULT_MAX_RESULTS = 1
URL = str
@dataclasses.dataclass(frozen=True, order=True, slots=True)
class SellerInfo:
name: str
@ -40,7 +39,6 @@ class StoreOfferProperty(enum.Enum):
AUCTION = enum.auto()
SOLD_OUT = enum.auto()
DISCOUNT = enum.auto()
PRE_ORDER = enum.auto()
@dataclasses.dataclass(frozen=True, order=True, slots=True)

View File

@ -7,7 +7,6 @@ import dataclasses
logger = logging.getLogger(__name__)
@dataclasses.dataclass(frozen=True)
class WishlistItem:
"""A single wishlished product."""
@ -20,6 +19,7 @@ class WishlistItem:
class WishlistClient(abc.ABC):
@abc.abstractmethod
def get_wishlist(self) -> Sequence[WishlistItem]:
pass

View File

@ -10,7 +10,8 @@ from setuptools import setup
PACKAGE_NAME = 'clients_protocol'
PACKAGE_DESCRIPTION = """
# Common HTTP/REST clients interface""".strip()
# Common HTTP/REST clients interface
""".strip()
PACKAGE_DESCRIPTION_SHORT = """
""".strip()
@ -26,9 +27,11 @@ def parse_version_file(text: str) -> str:
def find_python_packages() -> list[str]:
"""Find all python packages (directories containing __init__.py files)."""
"""
Find all python packages. (Directories containing __init__.py files.)
"""
root_path = Path(PACKAGE_NAME)
packages: set[str] = {PACKAGE_NAME}
packages: set[str] = set([PACKAGE_NAME])
# Search recursively
for init_file in root_path.rglob('__init__.py'):
@ -36,7 +39,6 @@ def find_python_packages() -> list[str]:
return sorted(packages)
with open(PACKAGE_NAME + '/_version.py') as f:
version = parse_version_file(f.read())

View File

@ -1,3 +1,5 @@
def test_init():
import clients_protocol
import clients_protocol.autoload