File: url.py

package info (click to toggle)
python-web-poet 0.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 908 kB
  • sloc: python: 6,112; makefile: 19
file content (27 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import annotations


class _Url:
    """Base URL class."""

    def __init__(self, url: str | _Url):
        if not isinstance(url, (str, _Url)):
            raise TypeError(
                f"`url` must be a str or an instance of _Url, "
                f"got {url.__class__} instance instead"
            )
        self._url = str(url)

    def __str__(self) -> str:
        return self._url

    def __repr__(self) -> str:
        return f"{self.__class__.__name__}({self._url!r})"


class ResponseUrl(_Url):
    """URL of the response"""


class RequestUrl(_Url):
    """URL of the request"""