Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/__init__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/_api.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/_error.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/_soft.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/_unix.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/_util.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/_windows.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/__pycache__/asyncio.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/filelock/_soft.py +47 -0
- wemm/lib/python3.10/site-packages/filelock/_unix.py +68 -0
- wemm/lib/python3.10/site-packages/filelock/_util.py +52 -0
- wemm/lib/python3.10/site-packages/hf_transfer-0.1.9.dist-info/INSTALLER +1 -0
- wemm/lib/python3.10/site-packages/hf_transfer-0.1.9.dist-info/METADATA +64 -0
- wemm/lib/python3.10/site-packages/hf_transfer-0.1.9.dist-info/WHEEL +4 -0
- wemm/lib/python3.10/site-packages/markupsafe/__init__.py +395 -0
- wemm/lib/python3.10/site-packages/markupsafe/__pycache__/__init__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/markupsafe/__pycache__/_native.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/markupsafe/_speedups.c +204 -0
- wemm/lib/python3.10/site-packages/markupsafe/_speedups.cpython-310-x86_64-linux-gnu.so +0 -0
- wemm/lib/python3.10/site-packages/markupsafe/_speedups.pyi +1 -0
- wemm/lib/python3.10/site-packages/markupsafe/py.typed +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__init__.py +4 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__main__.py +12 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__pycache__/__init__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__pycache__/__main__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__pycache__/core.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/cacert.pem +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/core.py +114 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/certifi/py.typed +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/__init__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/__version__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/_internal_utils.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/certs.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/compat.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/cookies.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/exceptions.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/hooks.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/models.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/packages.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/sessions.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/status_codes.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/models.py +1037 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/requests/structures.py +99 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-310.pyc +3 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__init__.py +36 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__pycache__/__init__.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__pycache__/_macos.cpython-310.pyc +0 -0
- wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__pycache__/_windows.cpython-310.pyc +0 -0
.gitattributes
CHANGED
|
@@ -226,3 +226,4 @@ wemm/lib/python3.10/site-packages/torch/lib/libcudnn.so.8 filter=lfs diff=lfs me
|
|
| 226 |
wemm/lib/python3.10/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
|
| 227 |
wemm/lib/python3.10/site-packages/sentencepiece/_sentencepiece.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 228 |
parrot/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda122.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 226 |
wemm/lib/python3.10/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
|
| 227 |
wemm/lib/python3.10/site-packages/sentencepiece/_sentencepiece.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 228 |
parrot/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda122.so filter=lfs diff=lfs merge=lfs -text
|
| 229 |
+
wemm/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.36 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/_api.cpython-310.pyc
ADDED
|
Binary file (12.9 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/_error.cpython-310.pyc
ADDED
|
Binary file (1.43 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/_soft.cpython-310.pyc
ADDED
|
Binary file (1.54 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/_unix.cpython-310.pyc
ADDED
|
Binary file (2.11 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/_util.cpython-310.pyc
ADDED
|
Binary file (1.49 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/_windows.cpython-310.pyc
ADDED
|
Binary file (2.06 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/__pycache__/asyncio.cpython-310.pyc
ADDED
|
Binary file (11.9 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/filelock/_soft.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from contextlib import suppress
|
| 6 |
+
from errno import EACCES, EEXIST
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
from ._api import BaseFileLock
|
| 10 |
+
from ._util import ensure_directory_exists, raise_on_not_writable_file
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class SoftFileLock(BaseFileLock):
|
| 14 |
+
"""Simply watches the existence of the lock file."""
|
| 15 |
+
|
| 16 |
+
def _acquire(self) -> None:
|
| 17 |
+
raise_on_not_writable_file(self.lock_file)
|
| 18 |
+
ensure_directory_exists(self.lock_file)
|
| 19 |
+
# first check for exists and read-only mode as the open will mask this case as EEXIST
|
| 20 |
+
flags = (
|
| 21 |
+
os.O_WRONLY # open for writing only
|
| 22 |
+
| os.O_CREAT
|
| 23 |
+
| os.O_EXCL # together with above raise EEXIST if the file specified by filename exists
|
| 24 |
+
| os.O_TRUNC # truncate the file to zero byte
|
| 25 |
+
)
|
| 26 |
+
try:
|
| 27 |
+
file_handler = os.open(self.lock_file, flags, self._context.mode)
|
| 28 |
+
except OSError as exception: # re-raise unless expected exception
|
| 29 |
+
if not (
|
| 30 |
+
exception.errno == EEXIST # lock already exist
|
| 31 |
+
or (exception.errno == EACCES and sys.platform == "win32") # has no access to this lock
|
| 32 |
+
): # pragma: win32 no cover
|
| 33 |
+
raise
|
| 34 |
+
else:
|
| 35 |
+
self._context.lock_file_fd = file_handler
|
| 36 |
+
|
| 37 |
+
def _release(self) -> None:
|
| 38 |
+
assert self._context.lock_file_fd is not None # noqa: S101
|
| 39 |
+
os.close(self._context.lock_file_fd) # the lock file is definitely not None
|
| 40 |
+
self._context.lock_file_fd = None
|
| 41 |
+
with suppress(OSError): # the file is already deleted and that's what we want
|
| 42 |
+
Path(self.lock_file).unlink()
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
__all__ = [
|
| 46 |
+
"SoftFileLock",
|
| 47 |
+
]
|
wemm/lib/python3.10/site-packages/filelock/_unix.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from contextlib import suppress
|
| 6 |
+
from errno import ENOSYS
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from typing import cast
|
| 9 |
+
|
| 10 |
+
from ._api import BaseFileLock
|
| 11 |
+
from ._util import ensure_directory_exists
|
| 12 |
+
|
| 13 |
+
#: a flag to indicate if the fcntl API is available
|
| 14 |
+
has_fcntl = False
|
| 15 |
+
if sys.platform == "win32": # pragma: win32 cover
|
| 16 |
+
|
| 17 |
+
class UnixFileLock(BaseFileLock):
|
| 18 |
+
"""Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems."""
|
| 19 |
+
|
| 20 |
+
def _acquire(self) -> None:
|
| 21 |
+
raise NotImplementedError
|
| 22 |
+
|
| 23 |
+
def _release(self) -> None:
|
| 24 |
+
raise NotImplementedError
|
| 25 |
+
|
| 26 |
+
else: # pragma: win32 no cover
|
| 27 |
+
try:
|
| 28 |
+
import fcntl
|
| 29 |
+
except ImportError:
|
| 30 |
+
pass
|
| 31 |
+
else:
|
| 32 |
+
has_fcntl = True
|
| 33 |
+
|
| 34 |
+
class UnixFileLock(BaseFileLock):
|
| 35 |
+
"""Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems."""
|
| 36 |
+
|
| 37 |
+
def _acquire(self) -> None:
|
| 38 |
+
ensure_directory_exists(self.lock_file)
|
| 39 |
+
open_flags = os.O_RDWR | os.O_TRUNC
|
| 40 |
+
if not Path(self.lock_file).exists():
|
| 41 |
+
open_flags |= os.O_CREAT
|
| 42 |
+
fd = os.open(self.lock_file, open_flags, self._context.mode)
|
| 43 |
+
with suppress(PermissionError): # This locked is not owned by this UID
|
| 44 |
+
os.fchmod(fd, self._context.mode)
|
| 45 |
+
try:
|
| 46 |
+
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
| 47 |
+
except OSError as exception:
|
| 48 |
+
os.close(fd)
|
| 49 |
+
if exception.errno == ENOSYS: # NotImplemented error
|
| 50 |
+
msg = "FileSystem does not appear to support flock; use SoftFileLock instead"
|
| 51 |
+
raise NotImplementedError(msg) from exception
|
| 52 |
+
else:
|
| 53 |
+
self._context.lock_file_fd = fd
|
| 54 |
+
|
| 55 |
+
def _release(self) -> None:
|
| 56 |
+
# Do not remove the lockfile:
|
| 57 |
+
# https://github.com/tox-dev/py-filelock/issues/31
|
| 58 |
+
# https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition
|
| 59 |
+
fd = cast(int, self._context.lock_file_fd)
|
| 60 |
+
self._context.lock_file_fd = None
|
| 61 |
+
fcntl.flock(fd, fcntl.LOCK_UN)
|
| 62 |
+
os.close(fd)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
__all__ = [
|
| 66 |
+
"UnixFileLock",
|
| 67 |
+
"has_fcntl",
|
| 68 |
+
]
|
wemm/lib/python3.10/site-packages/filelock/_util.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import stat
|
| 5 |
+
import sys
|
| 6 |
+
from errno import EACCES, EISDIR
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def raise_on_not_writable_file(filename: str) -> None:
|
| 11 |
+
"""
|
| 12 |
+
Raise an exception if attempting to open the file for writing would fail.
|
| 13 |
+
|
| 14 |
+
This is done so files that will never be writable can be separated from files that are writable but currently
|
| 15 |
+
locked.
|
| 16 |
+
|
| 17 |
+
:param filename: file to check
|
| 18 |
+
:raises OSError: as if the file was opened for writing.
|
| 19 |
+
|
| 20 |
+
"""
|
| 21 |
+
try: # use stat to do exists + can write to check without race condition
|
| 22 |
+
file_stat = os.stat(filename) # noqa: PTH116
|
| 23 |
+
except OSError:
|
| 24 |
+
return # swallow does not exist or other errors
|
| 25 |
+
|
| 26 |
+
if file_stat.st_mtime != 0: # if os.stat returns but modification is zero that's an invalid os.stat - ignore it
|
| 27 |
+
if not (file_stat.st_mode & stat.S_IWUSR):
|
| 28 |
+
raise PermissionError(EACCES, "Permission denied", filename)
|
| 29 |
+
|
| 30 |
+
if stat.S_ISDIR(file_stat.st_mode):
|
| 31 |
+
if sys.platform == "win32": # pragma: win32 cover
|
| 32 |
+
# On Windows, this is PermissionError
|
| 33 |
+
raise PermissionError(EACCES, "Permission denied", filename)
|
| 34 |
+
else: # pragma: win32 no cover # noqa: RET506
|
| 35 |
+
# On linux / macOS, this is IsADirectoryError
|
| 36 |
+
raise IsADirectoryError(EISDIR, "Is a directory", filename)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def ensure_directory_exists(filename: Path | str) -> None:
|
| 40 |
+
"""
|
| 41 |
+
Ensure the directory containing the file exists (create it if necessary).
|
| 42 |
+
|
| 43 |
+
:param filename: file.
|
| 44 |
+
|
| 45 |
+
"""
|
| 46 |
+
Path(filename).parent.mkdir(parents=True, exist_ok=True)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
__all__ = [
|
| 50 |
+
"ensure_directory_exists",
|
| 51 |
+
"raise_on_not_writable_file",
|
| 52 |
+
]
|
wemm/lib/python3.10/site-packages/hf_transfer-0.1.9.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
wemm/lib/python3.10/site-packages/hf_transfer-0.1.9.dist-info/METADATA
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: hf_transfer
|
| 3 |
+
Version: 0.1.9
|
| 4 |
+
Classifier: Programming Language :: Rust
|
| 5 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 6 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 7 |
+
License-File: LICENSE
|
| 8 |
+
Summary: Speed up file transfers with the Hugging Face Hub.
|
| 9 |
+
Requires-Python: >=3.7
|
| 10 |
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
| 11 |
+
Project-URL: Issues, https://github.com/huggingface/hf_transfer/issues
|
| 12 |
+
Project-URL: Repository, https://github.com/huggingface/hf_transfer.git
|
| 13 |
+
|
| 14 |
+
# HF Transfer
|
| 15 |
+
|
| 16 |
+
Speed up file transfers with the Hub.
|
| 17 |
+
|
| 18 |
+
# DISCLAIMER
|
| 19 |
+
|
| 20 |
+
This library is a power user tool, to go beyond `~500MB/s` on very high bandwidth
|
| 21 |
+
network, where Python cannot cap out the available bandwidth.
|
| 22 |
+
|
| 23 |
+
This is *not* meant to be a general usability tool.
|
| 24 |
+
It purposefully lacks progressbars and comes generally as-is.
|
| 25 |
+
|
| 26 |
+
Please file issues *only* if there's an issue on the underlying downloaded file.
|
| 27 |
+
|
| 28 |
+
## Contributing
|
| 29 |
+
|
| 30 |
+
```sh
|
| 31 |
+
python3 -m venv ~/.venv/hf_transfer
|
| 32 |
+
source ~/.venv/hf_transfer/bin/activate
|
| 33 |
+
pip install maturin
|
| 34 |
+
maturin develop
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### `huggingface_hub`
|
| 38 |
+
|
| 39 |
+
If you are working on changes with `huggingface_hub`
|
| 40 |
+
|
| 41 |
+
```sh
|
| 42 |
+
git clone git@github.com:huggingface/huggingface_hub.git
|
| 43 |
+
# git clone https://github.com/huggingface/huggingface_hub.git
|
| 44 |
+
|
| 45 |
+
cd huggingface_hub
|
| 46 |
+
python3 -m pip install -e ".[quality]"
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
You can use the following test script:
|
| 50 |
+
|
| 51 |
+
```py
|
| 52 |
+
import os
|
| 53 |
+
|
| 54 |
+
# os.environ["HF_ENDPOINT"] = "http://localhost:5564"
|
| 55 |
+
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 56 |
+
|
| 57 |
+
from huggingface_hub import HfApi, logging
|
| 58 |
+
|
| 59 |
+
logging.set_verbosity_debug()
|
| 60 |
+
hf = HfApi()
|
| 61 |
+
hf.upload_file(path_or_fileobj="/path/to/my/repo/some_file", path_in_repo="some_file", repo_id="my/repo", repo_type="model")
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
|
wemm/lib/python3.10/site-packages/hf_transfer-0.1.9.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: maturin (1.8.1)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64
|
wemm/lib/python3.10/site-packages/markupsafe/__init__.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import collections.abc as cabc
|
| 4 |
+
import string
|
| 5 |
+
import typing as t
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
from ._speedups import _escape_inner
|
| 9 |
+
except ImportError:
|
| 10 |
+
from ._native import _escape_inner
|
| 11 |
+
|
| 12 |
+
if t.TYPE_CHECKING:
|
| 13 |
+
import typing_extensions as te
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class _HasHTML(t.Protocol):
|
| 17 |
+
def __html__(self, /) -> str: ...
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class _TPEscape(t.Protocol):
|
| 21 |
+
def __call__(self, s: t.Any, /) -> Markup: ...
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def escape(s: t.Any, /) -> Markup:
|
| 25 |
+
"""Replace the characters ``&``, ``<``, ``>``, ``'``, and ``"`` in
|
| 26 |
+
the string with HTML-safe sequences. Use this if you need to display
|
| 27 |
+
text that might contain such characters in HTML.
|
| 28 |
+
|
| 29 |
+
If the object has an ``__html__`` method, it is called and the
|
| 30 |
+
return value is assumed to already be safe for HTML.
|
| 31 |
+
|
| 32 |
+
:param s: An object to be converted to a string and escaped.
|
| 33 |
+
:return: A :class:`Markup` string with the escaped text.
|
| 34 |
+
"""
|
| 35 |
+
# If the object is already a plain string, skip __html__ check and string
|
| 36 |
+
# conversion. This is the most common use case.
|
| 37 |
+
# Use type(s) instead of s.__class__ because a proxy object may be reporting
|
| 38 |
+
# the __class__ of the proxied value.
|
| 39 |
+
if type(s) is str:
|
| 40 |
+
return Markup(_escape_inner(s))
|
| 41 |
+
|
| 42 |
+
if hasattr(s, "__html__"):
|
| 43 |
+
return Markup(s.__html__())
|
| 44 |
+
|
| 45 |
+
return Markup(_escape_inner(str(s)))
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def escape_silent(s: t.Any | None, /) -> Markup:
|
| 49 |
+
"""Like :func:`escape` but treats ``None`` as the empty string.
|
| 50 |
+
Useful with optional values, as otherwise you get the string
|
| 51 |
+
``'None'`` when the value is ``None``.
|
| 52 |
+
|
| 53 |
+
>>> escape(None)
|
| 54 |
+
Markup('None')
|
| 55 |
+
>>> escape_silent(None)
|
| 56 |
+
Markup('')
|
| 57 |
+
"""
|
| 58 |
+
if s is None:
|
| 59 |
+
return Markup()
|
| 60 |
+
|
| 61 |
+
return escape(s)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def soft_str(s: t.Any, /) -> str:
|
| 65 |
+
"""Convert an object to a string if it isn't already. This preserves
|
| 66 |
+
a :class:`Markup` string rather than converting it back to a basic
|
| 67 |
+
string, so it will still be marked as safe and won't be escaped
|
| 68 |
+
again.
|
| 69 |
+
|
| 70 |
+
>>> value = escape("<User 1>")
|
| 71 |
+
>>> value
|
| 72 |
+
Markup('<User 1>')
|
| 73 |
+
>>> escape(str(value))
|
| 74 |
+
Markup('&lt;User 1&gt;')
|
| 75 |
+
>>> escape(soft_str(value))
|
| 76 |
+
Markup('<User 1>')
|
| 77 |
+
"""
|
| 78 |
+
if not isinstance(s, str):
|
| 79 |
+
return str(s)
|
| 80 |
+
|
| 81 |
+
return s
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class Markup(str):
|
| 85 |
+
"""A string that is ready to be safely inserted into an HTML or XML
|
| 86 |
+
document, either because it was escaped or because it was marked
|
| 87 |
+
safe.
|
| 88 |
+
|
| 89 |
+
Passing an object to the constructor converts it to text and wraps
|
| 90 |
+
it to mark it safe without escaping. To escape the text, use the
|
| 91 |
+
:meth:`escape` class method instead.
|
| 92 |
+
|
| 93 |
+
>>> Markup("Hello, <em>World</em>!")
|
| 94 |
+
Markup('Hello, <em>World</em>!')
|
| 95 |
+
>>> Markup(42)
|
| 96 |
+
Markup('42')
|
| 97 |
+
>>> Markup.escape("Hello, <em>World</em>!")
|
| 98 |
+
Markup('Hello <em>World</em>!')
|
| 99 |
+
|
| 100 |
+
This implements the ``__html__()`` interface that some frameworks
|
| 101 |
+
use. Passing an object that implements ``__html__()`` will wrap the
|
| 102 |
+
output of that method, marking it safe.
|
| 103 |
+
|
| 104 |
+
>>> class Foo:
|
| 105 |
+
... def __html__(self):
|
| 106 |
+
... return '<a href="/foo">foo</a>'
|
| 107 |
+
...
|
| 108 |
+
>>> Markup(Foo())
|
| 109 |
+
Markup('<a href="/foo">foo</a>')
|
| 110 |
+
|
| 111 |
+
This is a subclass of :class:`str`. It has the same methods, but
|
| 112 |
+
escapes their arguments and returns a ``Markup`` instance.
|
| 113 |
+
|
| 114 |
+
>>> Markup("<em>%s</em>") % ("foo & bar",)
|
| 115 |
+
Markup('<em>foo & bar</em>')
|
| 116 |
+
>>> Markup("<em>Hello</em> ") + "<foo>"
|
| 117 |
+
Markup('<em>Hello</em> <foo>')
|
| 118 |
+
"""
|
| 119 |
+
|
| 120 |
+
__slots__ = ()
|
| 121 |
+
|
| 122 |
+
def __new__(
|
| 123 |
+
cls, object: t.Any = "", encoding: str | None = None, errors: str = "strict"
|
| 124 |
+
) -> te.Self:
|
| 125 |
+
if hasattr(object, "__html__"):
|
| 126 |
+
object = object.__html__()
|
| 127 |
+
|
| 128 |
+
if encoding is None:
|
| 129 |
+
return super().__new__(cls, object)
|
| 130 |
+
|
| 131 |
+
return super().__new__(cls, object, encoding, errors)
|
| 132 |
+
|
| 133 |
+
def __html__(self, /) -> te.Self:
|
| 134 |
+
return self
|
| 135 |
+
|
| 136 |
+
def __add__(self, value: str | _HasHTML, /) -> te.Self:
|
| 137 |
+
if isinstance(value, str) or hasattr(value, "__html__"):
|
| 138 |
+
return self.__class__(super().__add__(self.escape(value)))
|
| 139 |
+
|
| 140 |
+
return NotImplemented
|
| 141 |
+
|
| 142 |
+
def __radd__(self, value: str | _HasHTML, /) -> te.Self:
|
| 143 |
+
if isinstance(value, str) or hasattr(value, "__html__"):
|
| 144 |
+
return self.escape(value).__add__(self)
|
| 145 |
+
|
| 146 |
+
return NotImplemented
|
| 147 |
+
|
| 148 |
+
def __mul__(self, value: t.SupportsIndex, /) -> te.Self:
|
| 149 |
+
return self.__class__(super().__mul__(value))
|
| 150 |
+
|
| 151 |
+
def __rmul__(self, value: t.SupportsIndex, /) -> te.Self:
|
| 152 |
+
return self.__class__(super().__mul__(value))
|
| 153 |
+
|
| 154 |
+
def __mod__(self, value: t.Any, /) -> te.Self:
|
| 155 |
+
if isinstance(value, tuple):
|
| 156 |
+
# a tuple of arguments, each wrapped
|
| 157 |
+
value = tuple(_MarkupEscapeHelper(x, self.escape) for x in value)
|
| 158 |
+
elif hasattr(type(value), "__getitem__") and not isinstance(value, str):
|
| 159 |
+
# a mapping of arguments, wrapped
|
| 160 |
+
value = _MarkupEscapeHelper(value, self.escape)
|
| 161 |
+
else:
|
| 162 |
+
# a single argument, wrapped with the helper and a tuple
|
| 163 |
+
value = (_MarkupEscapeHelper(value, self.escape),)
|
| 164 |
+
|
| 165 |
+
return self.__class__(super().__mod__(value))
|
| 166 |
+
|
| 167 |
+
def __repr__(self, /) -> str:
|
| 168 |
+
return f"{self.__class__.__name__}({super().__repr__()})"
|
| 169 |
+
|
| 170 |
+
def join(self, iterable: cabc.Iterable[str | _HasHTML], /) -> te.Self:
|
| 171 |
+
return self.__class__(super().join(map(self.escape, iterable)))
|
| 172 |
+
|
| 173 |
+
def split( # type: ignore[override]
|
| 174 |
+
self, /, sep: str | None = None, maxsplit: t.SupportsIndex = -1
|
| 175 |
+
) -> list[te.Self]:
|
| 176 |
+
return [self.__class__(v) for v in super().split(sep, maxsplit)]
|
| 177 |
+
|
| 178 |
+
def rsplit( # type: ignore[override]
|
| 179 |
+
self, /, sep: str | None = None, maxsplit: t.SupportsIndex = -1
|
| 180 |
+
) -> list[te.Self]:
|
| 181 |
+
return [self.__class__(v) for v in super().rsplit(sep, maxsplit)]
|
| 182 |
+
|
| 183 |
+
def splitlines( # type: ignore[override]
|
| 184 |
+
self, /, keepends: bool = False
|
| 185 |
+
) -> list[te.Self]:
|
| 186 |
+
return [self.__class__(v) for v in super().splitlines(keepends)]
|
| 187 |
+
|
| 188 |
+
def unescape(self, /) -> str:
|
| 189 |
+
"""Convert escaped markup back into a text string. This replaces
|
| 190 |
+
HTML entities with the characters they represent.
|
| 191 |
+
|
| 192 |
+
>>> Markup("Main » <em>About</em>").unescape()
|
| 193 |
+
'Main » <em>About</em>'
|
| 194 |
+
"""
|
| 195 |
+
from html import unescape
|
| 196 |
+
|
| 197 |
+
return unescape(str(self))
|
| 198 |
+
|
| 199 |
+
def striptags(self, /) -> str:
|
| 200 |
+
""":meth:`unescape` the markup, remove tags, and normalize
|
| 201 |
+
whitespace to single spaces.
|
| 202 |
+
|
| 203 |
+
>>> Markup("Main »\t<em>About</em>").striptags()
|
| 204 |
+
'Main » About'
|
| 205 |
+
"""
|
| 206 |
+
value = str(self)
|
| 207 |
+
|
| 208 |
+
# Look for comments then tags separately. Otherwise, a comment that
|
| 209 |
+
# contains a tag would end early, leaving some of the comment behind.
|
| 210 |
+
|
| 211 |
+
# keep finding comment start marks
|
| 212 |
+
while (start := value.find("<!--")) != -1:
|
| 213 |
+
# find a comment end mark beyond the start, otherwise stop
|
| 214 |
+
if (end := value.find("-->", start)) == -1:
|
| 215 |
+
break
|
| 216 |
+
|
| 217 |
+
value = f"{value[:start]}{value[end + 3:]}"
|
| 218 |
+
|
| 219 |
+
# remove tags using the same method
|
| 220 |
+
while (start := value.find("<")) != -1:
|
| 221 |
+
if (end := value.find(">", start)) == -1:
|
| 222 |
+
break
|
| 223 |
+
|
| 224 |
+
value = f"{value[:start]}{value[end + 1:]}"
|
| 225 |
+
|
| 226 |
+
# collapse spaces
|
| 227 |
+
value = " ".join(value.split())
|
| 228 |
+
return self.__class__(value).unescape()
|
| 229 |
+
|
| 230 |
+
@classmethod
|
| 231 |
+
def escape(cls, s: t.Any, /) -> te.Self:
|
| 232 |
+
"""Escape a string. Calls :func:`escape` and ensures that for
|
| 233 |
+
subclasses the correct type is returned.
|
| 234 |
+
"""
|
| 235 |
+
rv = escape(s)
|
| 236 |
+
|
| 237 |
+
if rv.__class__ is not cls:
|
| 238 |
+
return cls(rv)
|
| 239 |
+
|
| 240 |
+
return rv # type: ignore[return-value]
|
| 241 |
+
|
| 242 |
+
def __getitem__(self, key: t.SupportsIndex | slice, /) -> te.Self:
|
| 243 |
+
return self.__class__(super().__getitem__(key))
|
| 244 |
+
|
| 245 |
+
def capitalize(self, /) -> te.Self:
|
| 246 |
+
return self.__class__(super().capitalize())
|
| 247 |
+
|
| 248 |
+
def title(self, /) -> te.Self:
|
| 249 |
+
return self.__class__(super().title())
|
| 250 |
+
|
| 251 |
+
def lower(self, /) -> te.Self:
|
| 252 |
+
return self.__class__(super().lower())
|
| 253 |
+
|
| 254 |
+
def upper(self, /) -> te.Self:
|
| 255 |
+
return self.__class__(super().upper())
|
| 256 |
+
|
| 257 |
+
def replace(self, old: str, new: str, count: t.SupportsIndex = -1, /) -> te.Self:
|
| 258 |
+
return self.__class__(super().replace(old, self.escape(new), count))
|
| 259 |
+
|
| 260 |
+
def ljust(self, width: t.SupportsIndex, fillchar: str = " ", /) -> te.Self:
|
| 261 |
+
return self.__class__(super().ljust(width, self.escape(fillchar)))
|
| 262 |
+
|
| 263 |
+
def rjust(self, width: t.SupportsIndex, fillchar: str = " ", /) -> te.Self:
|
| 264 |
+
return self.__class__(super().rjust(width, self.escape(fillchar)))
|
| 265 |
+
|
| 266 |
+
def lstrip(self, chars: str | None = None, /) -> te.Self:
|
| 267 |
+
return self.__class__(super().lstrip(chars))
|
| 268 |
+
|
| 269 |
+
def rstrip(self, chars: str | None = None, /) -> te.Self:
|
| 270 |
+
return self.__class__(super().rstrip(chars))
|
| 271 |
+
|
| 272 |
+
def center(self, width: t.SupportsIndex, fillchar: str = " ", /) -> te.Self:
|
| 273 |
+
return self.__class__(super().center(width, self.escape(fillchar)))
|
| 274 |
+
|
| 275 |
+
def strip(self, chars: str | None = None, /) -> te.Self:
|
| 276 |
+
return self.__class__(super().strip(chars))
|
| 277 |
+
|
| 278 |
+
def translate(
|
| 279 |
+
self,
|
| 280 |
+
table: cabc.Mapping[int, str | int | None], # type: ignore[override]
|
| 281 |
+
/,
|
| 282 |
+
) -> str:
|
| 283 |
+
return self.__class__(super().translate(table))
|
| 284 |
+
|
| 285 |
+
def expandtabs(self, /, tabsize: t.SupportsIndex = 8) -> te.Self:
|
| 286 |
+
return self.__class__(super().expandtabs(tabsize))
|
| 287 |
+
|
| 288 |
+
def swapcase(self, /) -> te.Self:
|
| 289 |
+
return self.__class__(super().swapcase())
|
| 290 |
+
|
| 291 |
+
def zfill(self, width: t.SupportsIndex, /) -> te.Self:
|
| 292 |
+
return self.__class__(super().zfill(width))
|
| 293 |
+
|
| 294 |
+
def casefold(self, /) -> te.Self:
|
| 295 |
+
return self.__class__(super().casefold())
|
| 296 |
+
|
| 297 |
+
def removeprefix(self, prefix: str, /) -> te.Self:
|
| 298 |
+
return self.__class__(super().removeprefix(prefix))
|
| 299 |
+
|
| 300 |
+
def removesuffix(self, suffix: str) -> te.Self:
|
| 301 |
+
return self.__class__(super().removesuffix(suffix))
|
| 302 |
+
|
| 303 |
+
def partition(self, sep: str, /) -> tuple[te.Self, te.Self, te.Self]:
|
| 304 |
+
left, sep, right = super().partition(sep)
|
| 305 |
+
cls = self.__class__
|
| 306 |
+
return cls(left), cls(sep), cls(right)
|
| 307 |
+
|
| 308 |
+
def rpartition(self, sep: str, /) -> tuple[te.Self, te.Self, te.Self]:
|
| 309 |
+
left, sep, right = super().rpartition(sep)
|
| 310 |
+
cls = self.__class__
|
| 311 |
+
return cls(left), cls(sep), cls(right)
|
| 312 |
+
|
| 313 |
+
def format(self, *args: t.Any, **kwargs: t.Any) -> te.Self:
|
| 314 |
+
formatter = EscapeFormatter(self.escape)
|
| 315 |
+
return self.__class__(formatter.vformat(self, args, kwargs))
|
| 316 |
+
|
| 317 |
+
def format_map(
|
| 318 |
+
self,
|
| 319 |
+
mapping: cabc.Mapping[str, t.Any], # type: ignore[override]
|
| 320 |
+
/,
|
| 321 |
+
) -> te.Self:
|
| 322 |
+
formatter = EscapeFormatter(self.escape)
|
| 323 |
+
return self.__class__(formatter.vformat(self, (), mapping))
|
| 324 |
+
|
| 325 |
+
def __html_format__(self, format_spec: str, /) -> te.Self:
|
| 326 |
+
if format_spec:
|
| 327 |
+
raise ValueError("Unsupported format specification for Markup.")
|
| 328 |
+
|
| 329 |
+
return self
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
class EscapeFormatter(string.Formatter):
|
| 333 |
+
__slots__ = ("escape",)
|
| 334 |
+
|
| 335 |
+
def __init__(self, escape: _TPEscape) -> None:
|
| 336 |
+
self.escape: _TPEscape = escape
|
| 337 |
+
super().__init__()
|
| 338 |
+
|
| 339 |
+
def format_field(self, value: t.Any, format_spec: str) -> str:
|
| 340 |
+
if hasattr(value, "__html_format__"):
|
| 341 |
+
rv = value.__html_format__(format_spec)
|
| 342 |
+
elif hasattr(value, "__html__"):
|
| 343 |
+
if format_spec:
|
| 344 |
+
raise ValueError(
|
| 345 |
+
f"Format specifier {format_spec} given, but {type(value)} does not"
|
| 346 |
+
" define __html_format__. A class that defines __html__ must define"
|
| 347 |
+
" __html_format__ to work with format specifiers."
|
| 348 |
+
)
|
| 349 |
+
rv = value.__html__()
|
| 350 |
+
else:
|
| 351 |
+
# We need to make sure the format spec is str here as
|
| 352 |
+
# otherwise the wrong callback methods are invoked.
|
| 353 |
+
rv = super().format_field(value, str(format_spec))
|
| 354 |
+
return str(self.escape(rv))
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
class _MarkupEscapeHelper:
|
| 358 |
+
"""Helper for :meth:`Markup.__mod__`."""
|
| 359 |
+
|
| 360 |
+
__slots__ = ("obj", "escape")
|
| 361 |
+
|
| 362 |
+
def __init__(self, obj: t.Any, escape: _TPEscape) -> None:
|
| 363 |
+
self.obj: t.Any = obj
|
| 364 |
+
self.escape: _TPEscape = escape
|
| 365 |
+
|
| 366 |
+
def __getitem__(self, key: t.Any, /) -> te.Self:
|
| 367 |
+
return self.__class__(self.obj[key], self.escape)
|
| 368 |
+
|
| 369 |
+
def __str__(self, /) -> str:
|
| 370 |
+
return str(self.escape(self.obj))
|
| 371 |
+
|
| 372 |
+
def __repr__(self, /) -> str:
|
| 373 |
+
return str(self.escape(repr(self.obj)))
|
| 374 |
+
|
| 375 |
+
def __int__(self, /) -> int:
|
| 376 |
+
return int(self.obj)
|
| 377 |
+
|
| 378 |
+
def __float__(self, /) -> float:
|
| 379 |
+
return float(self.obj)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
def __getattr__(name: str) -> t.Any:
|
| 383 |
+
if name == "__version__":
|
| 384 |
+
import importlib.metadata
|
| 385 |
+
import warnings
|
| 386 |
+
|
| 387 |
+
warnings.warn(
|
| 388 |
+
"The '__version__' attribute is deprecated and will be removed in"
|
| 389 |
+
" MarkupSafe 3.1. Use feature detection, or"
|
| 390 |
+
' `importlib.metadata.version("markupsafe")`, instead.',
|
| 391 |
+
stacklevel=2,
|
| 392 |
+
)
|
| 393 |
+
return importlib.metadata.version("markupsafe")
|
| 394 |
+
|
| 395 |
+
raise AttributeError(name)
|
wemm/lib/python3.10/site-packages/markupsafe/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (15.4 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/markupsafe/__pycache__/_native.cpython-310.pyc
ADDED
|
Binary file (394 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/markupsafe/_speedups.c
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <Python.h>
|
| 2 |
+
|
| 3 |
+
#define GET_DELTA(inp, inp_end, delta) \
|
| 4 |
+
while (inp < inp_end) { \
|
| 5 |
+
switch (*inp++) { \
|
| 6 |
+
case '"': \
|
| 7 |
+
case '\'': \
|
| 8 |
+
case '&': \
|
| 9 |
+
delta += 4; \
|
| 10 |
+
break; \
|
| 11 |
+
case '<': \
|
| 12 |
+
case '>': \
|
| 13 |
+
delta += 3; \
|
| 14 |
+
break; \
|
| 15 |
+
} \
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#define DO_ESCAPE(inp, inp_end, outp) \
|
| 19 |
+
{ \
|
| 20 |
+
Py_ssize_t ncopy = 0; \
|
| 21 |
+
while (inp < inp_end) { \
|
| 22 |
+
switch (*inp) { \
|
| 23 |
+
case '"': \
|
| 24 |
+
memcpy(outp, inp-ncopy, sizeof(*outp)*ncopy); \
|
| 25 |
+
outp += ncopy; ncopy = 0; \
|
| 26 |
+
*outp++ = '&'; \
|
| 27 |
+
*outp++ = '#'; \
|
| 28 |
+
*outp++ = '3'; \
|
| 29 |
+
*outp++ = '4'; \
|
| 30 |
+
*outp++ = ';'; \
|
| 31 |
+
break; \
|
| 32 |
+
case '\'': \
|
| 33 |
+
memcpy(outp, inp-ncopy, sizeof(*outp)*ncopy); \
|
| 34 |
+
outp += ncopy; ncopy = 0; \
|
| 35 |
+
*outp++ = '&'; \
|
| 36 |
+
*outp++ = '#'; \
|
| 37 |
+
*outp++ = '3'; \
|
| 38 |
+
*outp++ = '9'; \
|
| 39 |
+
*outp++ = ';'; \
|
| 40 |
+
break; \
|
| 41 |
+
case '&': \
|
| 42 |
+
memcpy(outp, inp-ncopy, sizeof(*outp)*ncopy); \
|
| 43 |
+
outp += ncopy; ncopy = 0; \
|
| 44 |
+
*outp++ = '&'; \
|
| 45 |
+
*outp++ = 'a'; \
|
| 46 |
+
*outp++ = 'm'; \
|
| 47 |
+
*outp++ = 'p'; \
|
| 48 |
+
*outp++ = ';'; \
|
| 49 |
+
break; \
|
| 50 |
+
case '<': \
|
| 51 |
+
memcpy(outp, inp-ncopy, sizeof(*outp)*ncopy); \
|
| 52 |
+
outp += ncopy; ncopy = 0; \
|
| 53 |
+
*outp++ = '&'; \
|
| 54 |
+
*outp++ = 'l'; \
|
| 55 |
+
*outp++ = 't'; \
|
| 56 |
+
*outp++ = ';'; \
|
| 57 |
+
break; \
|
| 58 |
+
case '>': \
|
| 59 |
+
memcpy(outp, inp-ncopy, sizeof(*outp)*ncopy); \
|
| 60 |
+
outp += ncopy; ncopy = 0; \
|
| 61 |
+
*outp++ = '&'; \
|
| 62 |
+
*outp++ = 'g'; \
|
| 63 |
+
*outp++ = 't'; \
|
| 64 |
+
*outp++ = ';'; \
|
| 65 |
+
break; \
|
| 66 |
+
default: \
|
| 67 |
+
ncopy++; \
|
| 68 |
+
} \
|
| 69 |
+
inp++; \
|
| 70 |
+
} \
|
| 71 |
+
memcpy(outp, inp-ncopy, sizeof(*outp)*ncopy); \
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
static PyObject*
|
| 75 |
+
escape_unicode_kind1(PyUnicodeObject *in)
|
| 76 |
+
{
|
| 77 |
+
Py_UCS1 *inp = PyUnicode_1BYTE_DATA(in);
|
| 78 |
+
Py_UCS1 *inp_end = inp + PyUnicode_GET_LENGTH(in);
|
| 79 |
+
Py_UCS1 *outp;
|
| 80 |
+
PyObject *out;
|
| 81 |
+
Py_ssize_t delta = 0;
|
| 82 |
+
|
| 83 |
+
GET_DELTA(inp, inp_end, delta);
|
| 84 |
+
if (!delta) {
|
| 85 |
+
Py_INCREF(in);
|
| 86 |
+
return (PyObject*)in;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
out = PyUnicode_New(PyUnicode_GET_LENGTH(in) + delta,
|
| 90 |
+
PyUnicode_IS_ASCII(in) ? 127 : 255);
|
| 91 |
+
if (!out)
|
| 92 |
+
return NULL;
|
| 93 |
+
|
| 94 |
+
inp = PyUnicode_1BYTE_DATA(in);
|
| 95 |
+
outp = PyUnicode_1BYTE_DATA(out);
|
| 96 |
+
DO_ESCAPE(inp, inp_end, outp);
|
| 97 |
+
return out;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
static PyObject*
|
| 101 |
+
escape_unicode_kind2(PyUnicodeObject *in)
|
| 102 |
+
{
|
| 103 |
+
Py_UCS2 *inp = PyUnicode_2BYTE_DATA(in);
|
| 104 |
+
Py_UCS2 *inp_end = inp + PyUnicode_GET_LENGTH(in);
|
| 105 |
+
Py_UCS2 *outp;
|
| 106 |
+
PyObject *out;
|
| 107 |
+
Py_ssize_t delta = 0;
|
| 108 |
+
|
| 109 |
+
GET_DELTA(inp, inp_end, delta);
|
| 110 |
+
if (!delta) {
|
| 111 |
+
Py_INCREF(in);
|
| 112 |
+
return (PyObject*)in;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
out = PyUnicode_New(PyUnicode_GET_LENGTH(in) + delta, 65535);
|
| 116 |
+
if (!out)
|
| 117 |
+
return NULL;
|
| 118 |
+
|
| 119 |
+
inp = PyUnicode_2BYTE_DATA(in);
|
| 120 |
+
outp = PyUnicode_2BYTE_DATA(out);
|
| 121 |
+
DO_ESCAPE(inp, inp_end, outp);
|
| 122 |
+
return out;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
static PyObject*
|
| 127 |
+
escape_unicode_kind4(PyUnicodeObject *in)
|
| 128 |
+
{
|
| 129 |
+
Py_UCS4 *inp = PyUnicode_4BYTE_DATA(in);
|
| 130 |
+
Py_UCS4 *inp_end = inp + PyUnicode_GET_LENGTH(in);
|
| 131 |
+
Py_UCS4 *outp;
|
| 132 |
+
PyObject *out;
|
| 133 |
+
Py_ssize_t delta = 0;
|
| 134 |
+
|
| 135 |
+
GET_DELTA(inp, inp_end, delta);
|
| 136 |
+
if (!delta) {
|
| 137 |
+
Py_INCREF(in);
|
| 138 |
+
return (PyObject*)in;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
out = PyUnicode_New(PyUnicode_GET_LENGTH(in) + delta, 1114111);
|
| 142 |
+
if (!out)
|
| 143 |
+
return NULL;
|
| 144 |
+
|
| 145 |
+
inp = PyUnicode_4BYTE_DATA(in);
|
| 146 |
+
outp = PyUnicode_4BYTE_DATA(out);
|
| 147 |
+
DO_ESCAPE(inp, inp_end, outp);
|
| 148 |
+
return out;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
static PyObject*
|
| 152 |
+
escape_unicode(PyObject *self, PyObject *s)
|
| 153 |
+
{
|
| 154 |
+
if (!PyUnicode_Check(s))
|
| 155 |
+
return NULL;
|
| 156 |
+
|
| 157 |
+
// This check is no longer needed in Python 3.12.
|
| 158 |
+
if (PyUnicode_READY(s))
|
| 159 |
+
return NULL;
|
| 160 |
+
|
| 161 |
+
switch (PyUnicode_KIND(s)) {
|
| 162 |
+
case PyUnicode_1BYTE_KIND:
|
| 163 |
+
return escape_unicode_kind1((PyUnicodeObject*) s);
|
| 164 |
+
case PyUnicode_2BYTE_KIND:
|
| 165 |
+
return escape_unicode_kind2((PyUnicodeObject*) s);
|
| 166 |
+
case PyUnicode_4BYTE_KIND:
|
| 167 |
+
return escape_unicode_kind4((PyUnicodeObject*) s);
|
| 168 |
+
}
|
| 169 |
+
assert(0); /* shouldn't happen */
|
| 170 |
+
return NULL;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
static PyMethodDef module_methods[] = {
|
| 174 |
+
{"_escape_inner", (PyCFunction)escape_unicode, METH_O, NULL},
|
| 175 |
+
{NULL, NULL, 0, NULL} /* Sentinel */
|
| 176 |
+
};
|
| 177 |
+
|
| 178 |
+
static struct PyModuleDef module_definition = {
|
| 179 |
+
PyModuleDef_HEAD_INIT,
|
| 180 |
+
"markupsafe._speedups",
|
| 181 |
+
NULL,
|
| 182 |
+
-1,
|
| 183 |
+
module_methods,
|
| 184 |
+
NULL,
|
| 185 |
+
NULL,
|
| 186 |
+
NULL,
|
| 187 |
+
NULL
|
| 188 |
+
};
|
| 189 |
+
|
| 190 |
+
PyMODINIT_FUNC
|
| 191 |
+
PyInit__speedups(void)
|
| 192 |
+
{
|
| 193 |
+
PyObject *m = PyModule_Create(&module_definition);
|
| 194 |
+
|
| 195 |
+
if (m == NULL) {
|
| 196 |
+
return NULL;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
#ifdef Py_GIL_DISABLED
|
| 200 |
+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
| 201 |
+
#endif
|
| 202 |
+
|
| 203 |
+
return m;
|
| 204 |
+
}
|
wemm/lib/python3.10/site-packages/markupsafe/_speedups.cpython-310-x86_64-linux-gnu.so
ADDED
|
Binary file (35 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/markupsafe/_speedups.pyi
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
def _escape_inner(s: str, /) -> str: ...
|
wemm/lib/python3.10/site-packages/markupsafe/py.typed
ADDED
|
File without changes
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .core import contents, where
|
| 2 |
+
|
| 3 |
+
__all__ = ["contents", "where"]
|
| 4 |
+
__version__ = "2024.08.30"
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__main__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
|
| 3 |
+
from pip._vendor.certifi import contents, where
|
| 4 |
+
|
| 5 |
+
parser = argparse.ArgumentParser()
|
| 6 |
+
parser.add_argument("-c", "--contents", action="store_true")
|
| 7 |
+
args = parser.parse_args()
|
| 8 |
+
|
| 9 |
+
if args.contents:
|
| 10 |
+
print(contents())
|
| 11 |
+
else:
|
| 12 |
+
print(where())
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (282 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__pycache__/__main__.cpython-310.pyc
ADDED
|
Binary file (432 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/__pycache__/core.cpython-310.pyc
ADDED
|
Binary file (2.13 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/cacert.pem
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/core.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
certifi.py
|
| 3 |
+
~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
This module returns the installation location of cacert.pem or its contents.
|
| 6 |
+
"""
|
| 7 |
+
import sys
|
| 8 |
+
import atexit
|
| 9 |
+
|
| 10 |
+
def exit_cacert_ctx() -> None:
|
| 11 |
+
_CACERT_CTX.__exit__(None, None, None) # type: ignore[union-attr]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
if sys.version_info >= (3, 11):
|
| 15 |
+
|
| 16 |
+
from importlib.resources import as_file, files
|
| 17 |
+
|
| 18 |
+
_CACERT_CTX = None
|
| 19 |
+
_CACERT_PATH = None
|
| 20 |
+
|
| 21 |
+
def where() -> str:
|
| 22 |
+
# This is slightly terrible, but we want to delay extracting the file
|
| 23 |
+
# in cases where we're inside of a zipimport situation until someone
|
| 24 |
+
# actually calls where(), but we don't want to re-extract the file
|
| 25 |
+
# on every call of where(), so we'll do it once then store it in a
|
| 26 |
+
# global variable.
|
| 27 |
+
global _CACERT_CTX
|
| 28 |
+
global _CACERT_PATH
|
| 29 |
+
if _CACERT_PATH is None:
|
| 30 |
+
# This is slightly janky, the importlib.resources API wants you to
|
| 31 |
+
# manage the cleanup of this file, so it doesn't actually return a
|
| 32 |
+
# path, it returns a context manager that will give you the path
|
| 33 |
+
# when you enter it and will do any cleanup when you leave it. In
|
| 34 |
+
# the common case of not needing a temporary file, it will just
|
| 35 |
+
# return the file system location and the __exit__() is a no-op.
|
| 36 |
+
#
|
| 37 |
+
# We also have to hold onto the actual context manager, because
|
| 38 |
+
# it will do the cleanup whenever it gets garbage collected, so
|
| 39 |
+
# we will also store that at the global level as well.
|
| 40 |
+
_CACERT_CTX = as_file(files("pip._vendor.certifi").joinpath("cacert.pem"))
|
| 41 |
+
_CACERT_PATH = str(_CACERT_CTX.__enter__())
|
| 42 |
+
atexit.register(exit_cacert_ctx)
|
| 43 |
+
|
| 44 |
+
return _CACERT_PATH
|
| 45 |
+
|
| 46 |
+
def contents() -> str:
|
| 47 |
+
return files("pip._vendor.certifi").joinpath("cacert.pem").read_text(encoding="ascii")
|
| 48 |
+
|
| 49 |
+
elif sys.version_info >= (3, 7):
|
| 50 |
+
|
| 51 |
+
from importlib.resources import path as get_path, read_text
|
| 52 |
+
|
| 53 |
+
_CACERT_CTX = None
|
| 54 |
+
_CACERT_PATH = None
|
| 55 |
+
|
| 56 |
+
def where() -> str:
|
| 57 |
+
# This is slightly terrible, but we want to delay extracting the
|
| 58 |
+
# file in cases where we're inside of a zipimport situation until
|
| 59 |
+
# someone actually calls where(), but we don't want to re-extract
|
| 60 |
+
# the file on every call of where(), so we'll do it once then store
|
| 61 |
+
# it in a global variable.
|
| 62 |
+
global _CACERT_CTX
|
| 63 |
+
global _CACERT_PATH
|
| 64 |
+
if _CACERT_PATH is None:
|
| 65 |
+
# This is slightly janky, the importlib.resources API wants you
|
| 66 |
+
# to manage the cleanup of this file, so it doesn't actually
|
| 67 |
+
# return a path, it returns a context manager that will give
|
| 68 |
+
# you the path when you enter it and will do any cleanup when
|
| 69 |
+
# you leave it. In the common case of not needing a temporary
|
| 70 |
+
# file, it will just return the file system location and the
|
| 71 |
+
# __exit__() is a no-op.
|
| 72 |
+
#
|
| 73 |
+
# We also have to hold onto the actual context manager, because
|
| 74 |
+
# it will do the cleanup whenever it gets garbage collected, so
|
| 75 |
+
# we will also store that at the global level as well.
|
| 76 |
+
_CACERT_CTX = get_path("pip._vendor.certifi", "cacert.pem")
|
| 77 |
+
_CACERT_PATH = str(_CACERT_CTX.__enter__())
|
| 78 |
+
atexit.register(exit_cacert_ctx)
|
| 79 |
+
|
| 80 |
+
return _CACERT_PATH
|
| 81 |
+
|
| 82 |
+
def contents() -> str:
|
| 83 |
+
return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
|
| 84 |
+
|
| 85 |
+
else:
|
| 86 |
+
import os
|
| 87 |
+
import types
|
| 88 |
+
from typing import Union
|
| 89 |
+
|
| 90 |
+
Package = Union[types.ModuleType, str]
|
| 91 |
+
Resource = Union[str, "os.PathLike"]
|
| 92 |
+
|
| 93 |
+
# This fallback will work for Python versions prior to 3.7 that lack the
|
| 94 |
+
# importlib.resources module but relies on the existing `where` function
|
| 95 |
+
# so won't address issues with environments like PyOxidizer that don't set
|
| 96 |
+
# __file__ on modules.
|
| 97 |
+
def read_text(
|
| 98 |
+
package: Package,
|
| 99 |
+
resource: Resource,
|
| 100 |
+
encoding: str = 'utf-8',
|
| 101 |
+
errors: str = 'strict'
|
| 102 |
+
) -> str:
|
| 103 |
+
with open(where(), encoding=encoding) as data:
|
| 104 |
+
return data.read()
|
| 105 |
+
|
| 106 |
+
# If we don't have importlib.resources, then we will just do the old logic
|
| 107 |
+
# of assuming we're on the filesystem and munge the path directly.
|
| 108 |
+
def where() -> str:
|
| 109 |
+
f = os.path.dirname(__file__)
|
| 110 |
+
|
| 111 |
+
return os.path.join(f, "cacert.pem")
|
| 112 |
+
|
| 113 |
+
def contents() -> str:
|
| 114 |
+
return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
|
wemm/lib/python3.10/site-packages/pip/_vendor/certifi/py.typed
ADDED
|
File without changes
|
wemm/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (3.85 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/__version__.cpython-310.pyc
ADDED
|
Binary file (528 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/_internal_utils.cpython-310.pyc
ADDED
|
Binary file (1.6 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/certs.cpython-310.pyc
ADDED
|
Binary file (617 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/compat.cpython-310.pyc
ADDED
|
Binary file (1.5 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/cookies.cpython-310.pyc
ADDED
|
Binary file (18.7 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/exceptions.cpython-310.pyc
ADDED
|
Binary file (6.22 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/hooks.cpython-310.pyc
ADDED
|
Binary file (972 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/models.cpython-310.pyc
ADDED
|
Binary file (24.3 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/packages.cpython-310.pyc
ADDED
|
Binary file (718 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/sessions.cpython-310.pyc
ADDED
|
Binary file (19.7 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/__pycache__/status_codes.cpython-310.pyc
ADDED
|
Binary file (4.72 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/models.py
ADDED
|
@@ -0,0 +1,1037 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
requests.models
|
| 3 |
+
~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
This module contains the primary objects that power Requests.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import datetime
|
| 9 |
+
|
| 10 |
+
# Import encoding now, to avoid implicit import later.
|
| 11 |
+
# Implicit import within threads may cause LookupError when standard library is in a ZIP,
|
| 12 |
+
# such as in Embedded Python. See https://github.com/psf/requests/issues/3578.
|
| 13 |
+
import encodings.idna # noqa: F401
|
| 14 |
+
from io import UnsupportedOperation
|
| 15 |
+
|
| 16 |
+
from pip._vendor.urllib3.exceptions import (
|
| 17 |
+
DecodeError,
|
| 18 |
+
LocationParseError,
|
| 19 |
+
ProtocolError,
|
| 20 |
+
ReadTimeoutError,
|
| 21 |
+
SSLError,
|
| 22 |
+
)
|
| 23 |
+
from pip._vendor.urllib3.fields import RequestField
|
| 24 |
+
from pip._vendor.urllib3.filepost import encode_multipart_formdata
|
| 25 |
+
from pip._vendor.urllib3.util import parse_url
|
| 26 |
+
|
| 27 |
+
from ._internal_utils import to_native_string, unicode_is_ascii
|
| 28 |
+
from .auth import HTTPBasicAuth
|
| 29 |
+
from .compat import (
|
| 30 |
+
Callable,
|
| 31 |
+
JSONDecodeError,
|
| 32 |
+
Mapping,
|
| 33 |
+
basestring,
|
| 34 |
+
builtin_str,
|
| 35 |
+
chardet,
|
| 36 |
+
cookielib,
|
| 37 |
+
)
|
| 38 |
+
from .compat import json as complexjson
|
| 39 |
+
from .compat import urlencode, urlsplit, urlunparse
|
| 40 |
+
from .cookies import _copy_cookie_jar, cookiejar_from_dict, get_cookie_header
|
| 41 |
+
from .exceptions import (
|
| 42 |
+
ChunkedEncodingError,
|
| 43 |
+
ConnectionError,
|
| 44 |
+
ContentDecodingError,
|
| 45 |
+
HTTPError,
|
| 46 |
+
InvalidJSONError,
|
| 47 |
+
InvalidURL,
|
| 48 |
+
)
|
| 49 |
+
from .exceptions import JSONDecodeError as RequestsJSONDecodeError
|
| 50 |
+
from .exceptions import MissingSchema
|
| 51 |
+
from .exceptions import SSLError as RequestsSSLError
|
| 52 |
+
from .exceptions import StreamConsumedError
|
| 53 |
+
from .hooks import default_hooks
|
| 54 |
+
from .status_codes import codes
|
| 55 |
+
from .structures import CaseInsensitiveDict
|
| 56 |
+
from .utils import (
|
| 57 |
+
check_header_validity,
|
| 58 |
+
get_auth_from_url,
|
| 59 |
+
guess_filename,
|
| 60 |
+
guess_json_utf,
|
| 61 |
+
iter_slices,
|
| 62 |
+
parse_header_links,
|
| 63 |
+
requote_uri,
|
| 64 |
+
stream_decode_response_unicode,
|
| 65 |
+
super_len,
|
| 66 |
+
to_key_val_list,
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
#: The set of HTTP status codes that indicate an automatically
|
| 70 |
+
#: processable redirect.
|
| 71 |
+
REDIRECT_STATI = (
|
| 72 |
+
codes.moved, # 301
|
| 73 |
+
codes.found, # 302
|
| 74 |
+
codes.other, # 303
|
| 75 |
+
codes.temporary_redirect, # 307
|
| 76 |
+
codes.permanent_redirect, # 308
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
DEFAULT_REDIRECT_LIMIT = 30
|
| 80 |
+
CONTENT_CHUNK_SIZE = 10 * 1024
|
| 81 |
+
ITER_CHUNK_SIZE = 512
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class RequestEncodingMixin:
|
| 85 |
+
@property
|
| 86 |
+
def path_url(self):
|
| 87 |
+
"""Build the path URL to use."""
|
| 88 |
+
|
| 89 |
+
url = []
|
| 90 |
+
|
| 91 |
+
p = urlsplit(self.url)
|
| 92 |
+
|
| 93 |
+
path = p.path
|
| 94 |
+
if not path:
|
| 95 |
+
path = "/"
|
| 96 |
+
|
| 97 |
+
url.append(path)
|
| 98 |
+
|
| 99 |
+
query = p.query
|
| 100 |
+
if query:
|
| 101 |
+
url.append("?")
|
| 102 |
+
url.append(query)
|
| 103 |
+
|
| 104 |
+
return "".join(url)
|
| 105 |
+
|
| 106 |
+
@staticmethod
|
| 107 |
+
def _encode_params(data):
|
| 108 |
+
"""Encode parameters in a piece of data.
|
| 109 |
+
|
| 110 |
+
Will successfully encode parameters when passed as a dict or a list of
|
| 111 |
+
2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
|
| 112 |
+
if parameters are supplied as a dict.
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
if isinstance(data, (str, bytes)):
|
| 116 |
+
return data
|
| 117 |
+
elif hasattr(data, "read"):
|
| 118 |
+
return data
|
| 119 |
+
elif hasattr(data, "__iter__"):
|
| 120 |
+
result = []
|
| 121 |
+
for k, vs in to_key_val_list(data):
|
| 122 |
+
if isinstance(vs, basestring) or not hasattr(vs, "__iter__"):
|
| 123 |
+
vs = [vs]
|
| 124 |
+
for v in vs:
|
| 125 |
+
if v is not None:
|
| 126 |
+
result.append(
|
| 127 |
+
(
|
| 128 |
+
k.encode("utf-8") if isinstance(k, str) else k,
|
| 129 |
+
v.encode("utf-8") if isinstance(v, str) else v,
|
| 130 |
+
)
|
| 131 |
+
)
|
| 132 |
+
return urlencode(result, doseq=True)
|
| 133 |
+
else:
|
| 134 |
+
return data
|
| 135 |
+
|
| 136 |
+
@staticmethod
|
| 137 |
+
def _encode_files(files, data):
|
| 138 |
+
"""Build the body for a multipart/form-data request.
|
| 139 |
+
|
| 140 |
+
Will successfully encode files when passed as a dict or a list of
|
| 141 |
+
tuples. Order is retained if data is a list of tuples but arbitrary
|
| 142 |
+
if parameters are supplied as a dict.
|
| 143 |
+
The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype)
|
| 144 |
+
or 4-tuples (filename, fileobj, contentype, custom_headers).
|
| 145 |
+
"""
|
| 146 |
+
if not files:
|
| 147 |
+
raise ValueError("Files must be provided.")
|
| 148 |
+
elif isinstance(data, basestring):
|
| 149 |
+
raise ValueError("Data must not be a string.")
|
| 150 |
+
|
| 151 |
+
new_fields = []
|
| 152 |
+
fields = to_key_val_list(data or {})
|
| 153 |
+
files = to_key_val_list(files or {})
|
| 154 |
+
|
| 155 |
+
for field, val in fields:
|
| 156 |
+
if isinstance(val, basestring) or not hasattr(val, "__iter__"):
|
| 157 |
+
val = [val]
|
| 158 |
+
for v in val:
|
| 159 |
+
if v is not None:
|
| 160 |
+
# Don't call str() on bytestrings: in Py3 it all goes wrong.
|
| 161 |
+
if not isinstance(v, bytes):
|
| 162 |
+
v = str(v)
|
| 163 |
+
|
| 164 |
+
new_fields.append(
|
| 165 |
+
(
|
| 166 |
+
field.decode("utf-8")
|
| 167 |
+
if isinstance(field, bytes)
|
| 168 |
+
else field,
|
| 169 |
+
v.encode("utf-8") if isinstance(v, str) else v,
|
| 170 |
+
)
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
for k, v in files:
|
| 174 |
+
# support for explicit filename
|
| 175 |
+
ft = None
|
| 176 |
+
fh = None
|
| 177 |
+
if isinstance(v, (tuple, list)):
|
| 178 |
+
if len(v) == 2:
|
| 179 |
+
fn, fp = v
|
| 180 |
+
elif len(v) == 3:
|
| 181 |
+
fn, fp, ft = v
|
| 182 |
+
else:
|
| 183 |
+
fn, fp, ft, fh = v
|
| 184 |
+
else:
|
| 185 |
+
fn = guess_filename(v) or k
|
| 186 |
+
fp = v
|
| 187 |
+
|
| 188 |
+
if isinstance(fp, (str, bytes, bytearray)):
|
| 189 |
+
fdata = fp
|
| 190 |
+
elif hasattr(fp, "read"):
|
| 191 |
+
fdata = fp.read()
|
| 192 |
+
elif fp is None:
|
| 193 |
+
continue
|
| 194 |
+
else:
|
| 195 |
+
fdata = fp
|
| 196 |
+
|
| 197 |
+
rf = RequestField(name=k, data=fdata, filename=fn, headers=fh)
|
| 198 |
+
rf.make_multipart(content_type=ft)
|
| 199 |
+
new_fields.append(rf)
|
| 200 |
+
|
| 201 |
+
body, content_type = encode_multipart_formdata(new_fields)
|
| 202 |
+
|
| 203 |
+
return body, content_type
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
class RequestHooksMixin:
|
| 207 |
+
def register_hook(self, event, hook):
|
| 208 |
+
"""Properly register a hook."""
|
| 209 |
+
|
| 210 |
+
if event not in self.hooks:
|
| 211 |
+
raise ValueError(f'Unsupported event specified, with event name "{event}"')
|
| 212 |
+
|
| 213 |
+
if isinstance(hook, Callable):
|
| 214 |
+
self.hooks[event].append(hook)
|
| 215 |
+
elif hasattr(hook, "__iter__"):
|
| 216 |
+
self.hooks[event].extend(h for h in hook if isinstance(h, Callable))
|
| 217 |
+
|
| 218 |
+
def deregister_hook(self, event, hook):
|
| 219 |
+
"""Deregister a previously registered hook.
|
| 220 |
+
Returns True if the hook existed, False if not.
|
| 221 |
+
"""
|
| 222 |
+
|
| 223 |
+
try:
|
| 224 |
+
self.hooks[event].remove(hook)
|
| 225 |
+
return True
|
| 226 |
+
except ValueError:
|
| 227 |
+
return False
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
class Request(RequestHooksMixin):
|
| 231 |
+
"""A user-created :class:`Request <Request>` object.
|
| 232 |
+
|
| 233 |
+
Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server.
|
| 234 |
+
|
| 235 |
+
:param method: HTTP method to use.
|
| 236 |
+
:param url: URL to send.
|
| 237 |
+
:param headers: dictionary of headers to send.
|
| 238 |
+
:param files: dictionary of {filename: fileobject} files to multipart upload.
|
| 239 |
+
:param data: the body to attach to the request. If a dictionary or
|
| 240 |
+
list of tuples ``[(key, value)]`` is provided, form-encoding will
|
| 241 |
+
take place.
|
| 242 |
+
:param json: json for the body to attach to the request (if files or data is not specified).
|
| 243 |
+
:param params: URL parameters to append to the URL. If a dictionary or
|
| 244 |
+
list of tuples ``[(key, value)]`` is provided, form-encoding will
|
| 245 |
+
take place.
|
| 246 |
+
:param auth: Auth handler or (user, pass) tuple.
|
| 247 |
+
:param cookies: dictionary or CookieJar of cookies to attach to this request.
|
| 248 |
+
:param hooks: dictionary of callback hooks, for internal usage.
|
| 249 |
+
|
| 250 |
+
Usage::
|
| 251 |
+
|
| 252 |
+
>>> import requests
|
| 253 |
+
>>> req = requests.Request('GET', 'https://httpbin.org/get')
|
| 254 |
+
>>> req.prepare()
|
| 255 |
+
<PreparedRequest [GET]>
|
| 256 |
+
"""
|
| 257 |
+
|
| 258 |
+
def __init__(
|
| 259 |
+
self,
|
| 260 |
+
method=None,
|
| 261 |
+
url=None,
|
| 262 |
+
headers=None,
|
| 263 |
+
files=None,
|
| 264 |
+
data=None,
|
| 265 |
+
params=None,
|
| 266 |
+
auth=None,
|
| 267 |
+
cookies=None,
|
| 268 |
+
hooks=None,
|
| 269 |
+
json=None,
|
| 270 |
+
):
|
| 271 |
+
# Default empty dicts for dict params.
|
| 272 |
+
data = [] if data is None else data
|
| 273 |
+
files = [] if files is None else files
|
| 274 |
+
headers = {} if headers is None else headers
|
| 275 |
+
params = {} if params is None else params
|
| 276 |
+
hooks = {} if hooks is None else hooks
|
| 277 |
+
|
| 278 |
+
self.hooks = default_hooks()
|
| 279 |
+
for k, v in list(hooks.items()):
|
| 280 |
+
self.register_hook(event=k, hook=v)
|
| 281 |
+
|
| 282 |
+
self.method = method
|
| 283 |
+
self.url = url
|
| 284 |
+
self.headers = headers
|
| 285 |
+
self.files = files
|
| 286 |
+
self.data = data
|
| 287 |
+
self.json = json
|
| 288 |
+
self.params = params
|
| 289 |
+
self.auth = auth
|
| 290 |
+
self.cookies = cookies
|
| 291 |
+
|
| 292 |
+
def __repr__(self):
|
| 293 |
+
return f"<Request [{self.method}]>"
|
| 294 |
+
|
| 295 |
+
def prepare(self):
|
| 296 |
+
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it."""
|
| 297 |
+
p = PreparedRequest()
|
| 298 |
+
p.prepare(
|
| 299 |
+
method=self.method,
|
| 300 |
+
url=self.url,
|
| 301 |
+
headers=self.headers,
|
| 302 |
+
files=self.files,
|
| 303 |
+
data=self.data,
|
| 304 |
+
json=self.json,
|
| 305 |
+
params=self.params,
|
| 306 |
+
auth=self.auth,
|
| 307 |
+
cookies=self.cookies,
|
| 308 |
+
hooks=self.hooks,
|
| 309 |
+
)
|
| 310 |
+
return p
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
| 314 |
+
"""The fully mutable :class:`PreparedRequest <PreparedRequest>` object,
|
| 315 |
+
containing the exact bytes that will be sent to the server.
|
| 316 |
+
|
| 317 |
+
Instances are generated from a :class:`Request <Request>` object, and
|
| 318 |
+
should not be instantiated manually; doing so may produce undesirable
|
| 319 |
+
effects.
|
| 320 |
+
|
| 321 |
+
Usage::
|
| 322 |
+
|
| 323 |
+
>>> import requests
|
| 324 |
+
>>> req = requests.Request('GET', 'https://httpbin.org/get')
|
| 325 |
+
>>> r = req.prepare()
|
| 326 |
+
>>> r
|
| 327 |
+
<PreparedRequest [GET]>
|
| 328 |
+
|
| 329 |
+
>>> s = requests.Session()
|
| 330 |
+
>>> s.send(r)
|
| 331 |
+
<Response [200]>
|
| 332 |
+
"""
|
| 333 |
+
|
| 334 |
+
def __init__(self):
|
| 335 |
+
#: HTTP verb to send to the server.
|
| 336 |
+
self.method = None
|
| 337 |
+
#: HTTP URL to send the request to.
|
| 338 |
+
self.url = None
|
| 339 |
+
#: dictionary of HTTP headers.
|
| 340 |
+
self.headers = None
|
| 341 |
+
# The `CookieJar` used to create the Cookie header will be stored here
|
| 342 |
+
# after prepare_cookies is called
|
| 343 |
+
self._cookies = None
|
| 344 |
+
#: request body to send to the server.
|
| 345 |
+
self.body = None
|
| 346 |
+
#: dictionary of callback hooks, for internal usage.
|
| 347 |
+
self.hooks = default_hooks()
|
| 348 |
+
#: integer denoting starting position of a readable file-like body.
|
| 349 |
+
self._body_position = None
|
| 350 |
+
|
| 351 |
+
def prepare(
|
| 352 |
+
self,
|
| 353 |
+
method=None,
|
| 354 |
+
url=None,
|
| 355 |
+
headers=None,
|
| 356 |
+
files=None,
|
| 357 |
+
data=None,
|
| 358 |
+
params=None,
|
| 359 |
+
auth=None,
|
| 360 |
+
cookies=None,
|
| 361 |
+
hooks=None,
|
| 362 |
+
json=None,
|
| 363 |
+
):
|
| 364 |
+
"""Prepares the entire request with the given parameters."""
|
| 365 |
+
|
| 366 |
+
self.prepare_method(method)
|
| 367 |
+
self.prepare_url(url, params)
|
| 368 |
+
self.prepare_headers(headers)
|
| 369 |
+
self.prepare_cookies(cookies)
|
| 370 |
+
self.prepare_body(data, files, json)
|
| 371 |
+
self.prepare_auth(auth, url)
|
| 372 |
+
|
| 373 |
+
# Note that prepare_auth must be last to enable authentication schemes
|
| 374 |
+
# such as OAuth to work on a fully prepared request.
|
| 375 |
+
|
| 376 |
+
# This MUST go after prepare_auth. Authenticators could add a hook
|
| 377 |
+
self.prepare_hooks(hooks)
|
| 378 |
+
|
| 379 |
+
def __repr__(self):
|
| 380 |
+
return f"<PreparedRequest [{self.method}]>"
|
| 381 |
+
|
| 382 |
+
def copy(self):
|
| 383 |
+
p = PreparedRequest()
|
| 384 |
+
p.method = self.method
|
| 385 |
+
p.url = self.url
|
| 386 |
+
p.headers = self.headers.copy() if self.headers is not None else None
|
| 387 |
+
p._cookies = _copy_cookie_jar(self._cookies)
|
| 388 |
+
p.body = self.body
|
| 389 |
+
p.hooks = self.hooks
|
| 390 |
+
p._body_position = self._body_position
|
| 391 |
+
return p
|
| 392 |
+
|
| 393 |
+
def prepare_method(self, method):
|
| 394 |
+
"""Prepares the given HTTP method."""
|
| 395 |
+
self.method = method
|
| 396 |
+
if self.method is not None:
|
| 397 |
+
self.method = to_native_string(self.method.upper())
|
| 398 |
+
|
| 399 |
+
@staticmethod
|
| 400 |
+
def _get_idna_encoded_host(host):
|
| 401 |
+
from pip._vendor import idna
|
| 402 |
+
|
| 403 |
+
try:
|
| 404 |
+
host = idna.encode(host, uts46=True).decode("utf-8")
|
| 405 |
+
except idna.IDNAError:
|
| 406 |
+
raise UnicodeError
|
| 407 |
+
return host
|
| 408 |
+
|
| 409 |
+
def prepare_url(self, url, params):
|
| 410 |
+
"""Prepares the given HTTP URL."""
|
| 411 |
+
#: Accept objects that have string representations.
|
| 412 |
+
#: We're unable to blindly call unicode/str functions
|
| 413 |
+
#: as this will include the bytestring indicator (b'')
|
| 414 |
+
#: on python 3.x.
|
| 415 |
+
#: https://github.com/psf/requests/pull/2238
|
| 416 |
+
if isinstance(url, bytes):
|
| 417 |
+
url = url.decode("utf8")
|
| 418 |
+
else:
|
| 419 |
+
url = str(url)
|
| 420 |
+
|
| 421 |
+
# Remove leading whitespaces from url
|
| 422 |
+
url = url.lstrip()
|
| 423 |
+
|
| 424 |
+
# Don't do any URL preparation for non-HTTP schemes like `mailto`,
|
| 425 |
+
# `data` etc to work around exceptions from `url_parse`, which
|
| 426 |
+
# handles RFC 3986 only.
|
| 427 |
+
if ":" in url and not url.lower().startswith("http"):
|
| 428 |
+
self.url = url
|
| 429 |
+
return
|
| 430 |
+
|
| 431 |
+
# Support for unicode domain names and paths.
|
| 432 |
+
try:
|
| 433 |
+
scheme, auth, host, port, path, query, fragment = parse_url(url)
|
| 434 |
+
except LocationParseError as e:
|
| 435 |
+
raise InvalidURL(*e.args)
|
| 436 |
+
|
| 437 |
+
if not scheme:
|
| 438 |
+
raise MissingSchema(
|
| 439 |
+
f"Invalid URL {url!r}: No scheme supplied. "
|
| 440 |
+
f"Perhaps you meant https://{url}?"
|
| 441 |
+
)
|
| 442 |
+
|
| 443 |
+
if not host:
|
| 444 |
+
raise InvalidURL(f"Invalid URL {url!r}: No host supplied")
|
| 445 |
+
|
| 446 |
+
# In general, we want to try IDNA encoding the hostname if the string contains
|
| 447 |
+
# non-ASCII characters. This allows users to automatically get the correct IDNA
|
| 448 |
+
# behaviour. For strings containing only ASCII characters, we need to also verify
|
| 449 |
+
# it doesn't start with a wildcard (*), before allowing the unencoded hostname.
|
| 450 |
+
if not unicode_is_ascii(host):
|
| 451 |
+
try:
|
| 452 |
+
host = self._get_idna_encoded_host(host)
|
| 453 |
+
except UnicodeError:
|
| 454 |
+
raise InvalidURL("URL has an invalid label.")
|
| 455 |
+
elif host.startswith(("*", ".")):
|
| 456 |
+
raise InvalidURL("URL has an invalid label.")
|
| 457 |
+
|
| 458 |
+
# Carefully reconstruct the network location
|
| 459 |
+
netloc = auth or ""
|
| 460 |
+
if netloc:
|
| 461 |
+
netloc += "@"
|
| 462 |
+
netloc += host
|
| 463 |
+
if port:
|
| 464 |
+
netloc += f":{port}"
|
| 465 |
+
|
| 466 |
+
# Bare domains aren't valid URLs.
|
| 467 |
+
if not path:
|
| 468 |
+
path = "/"
|
| 469 |
+
|
| 470 |
+
if isinstance(params, (str, bytes)):
|
| 471 |
+
params = to_native_string(params)
|
| 472 |
+
|
| 473 |
+
enc_params = self._encode_params(params)
|
| 474 |
+
if enc_params:
|
| 475 |
+
if query:
|
| 476 |
+
query = f"{query}&{enc_params}"
|
| 477 |
+
else:
|
| 478 |
+
query = enc_params
|
| 479 |
+
|
| 480 |
+
url = requote_uri(urlunparse([scheme, netloc, path, None, query, fragment]))
|
| 481 |
+
self.url = url
|
| 482 |
+
|
| 483 |
+
def prepare_headers(self, headers):
|
| 484 |
+
"""Prepares the given HTTP headers."""
|
| 485 |
+
|
| 486 |
+
self.headers = CaseInsensitiveDict()
|
| 487 |
+
if headers:
|
| 488 |
+
for header in headers.items():
|
| 489 |
+
# Raise exception on invalid header value.
|
| 490 |
+
check_header_validity(header)
|
| 491 |
+
name, value = header
|
| 492 |
+
self.headers[to_native_string(name)] = value
|
| 493 |
+
|
| 494 |
+
def prepare_body(self, data, files, json=None):
|
| 495 |
+
"""Prepares the given HTTP body data."""
|
| 496 |
+
|
| 497 |
+
# Check if file, fo, generator, iterator.
|
| 498 |
+
# If not, run through normal process.
|
| 499 |
+
|
| 500 |
+
# Nottin' on you.
|
| 501 |
+
body = None
|
| 502 |
+
content_type = None
|
| 503 |
+
|
| 504 |
+
if not data and json is not None:
|
| 505 |
+
# urllib3 requires a bytes-like body. Python 2's json.dumps
|
| 506 |
+
# provides this natively, but Python 3 gives a Unicode string.
|
| 507 |
+
content_type = "application/json"
|
| 508 |
+
|
| 509 |
+
try:
|
| 510 |
+
body = complexjson.dumps(json, allow_nan=False)
|
| 511 |
+
except ValueError as ve:
|
| 512 |
+
raise InvalidJSONError(ve, request=self)
|
| 513 |
+
|
| 514 |
+
if not isinstance(body, bytes):
|
| 515 |
+
body = body.encode("utf-8")
|
| 516 |
+
|
| 517 |
+
is_stream = all(
|
| 518 |
+
[
|
| 519 |
+
hasattr(data, "__iter__"),
|
| 520 |
+
not isinstance(data, (basestring, list, tuple, Mapping)),
|
| 521 |
+
]
|
| 522 |
+
)
|
| 523 |
+
|
| 524 |
+
if is_stream:
|
| 525 |
+
try:
|
| 526 |
+
length = super_len(data)
|
| 527 |
+
except (TypeError, AttributeError, UnsupportedOperation):
|
| 528 |
+
length = None
|
| 529 |
+
|
| 530 |
+
body = data
|
| 531 |
+
|
| 532 |
+
if getattr(body, "tell", None) is not None:
|
| 533 |
+
# Record the current file position before reading.
|
| 534 |
+
# This will allow us to rewind a file in the event
|
| 535 |
+
# of a redirect.
|
| 536 |
+
try:
|
| 537 |
+
self._body_position = body.tell()
|
| 538 |
+
except OSError:
|
| 539 |
+
# This differentiates from None, allowing us to catch
|
| 540 |
+
# a failed `tell()` later when trying to rewind the body
|
| 541 |
+
self._body_position = object()
|
| 542 |
+
|
| 543 |
+
if files:
|
| 544 |
+
raise NotImplementedError(
|
| 545 |
+
"Streamed bodies and files are mutually exclusive."
|
| 546 |
+
)
|
| 547 |
+
|
| 548 |
+
if length:
|
| 549 |
+
self.headers["Content-Length"] = builtin_str(length)
|
| 550 |
+
else:
|
| 551 |
+
self.headers["Transfer-Encoding"] = "chunked"
|
| 552 |
+
else:
|
| 553 |
+
# Multi-part file uploads.
|
| 554 |
+
if files:
|
| 555 |
+
(body, content_type) = self._encode_files(files, data)
|
| 556 |
+
else:
|
| 557 |
+
if data:
|
| 558 |
+
body = self._encode_params(data)
|
| 559 |
+
if isinstance(data, basestring) or hasattr(data, "read"):
|
| 560 |
+
content_type = None
|
| 561 |
+
else:
|
| 562 |
+
content_type = "application/x-www-form-urlencoded"
|
| 563 |
+
|
| 564 |
+
self.prepare_content_length(body)
|
| 565 |
+
|
| 566 |
+
# Add content-type if it wasn't explicitly provided.
|
| 567 |
+
if content_type and ("content-type" not in self.headers):
|
| 568 |
+
self.headers["Content-Type"] = content_type
|
| 569 |
+
|
| 570 |
+
self.body = body
|
| 571 |
+
|
| 572 |
+
def prepare_content_length(self, body):
|
| 573 |
+
"""Prepare Content-Length header based on request method and body"""
|
| 574 |
+
if body is not None:
|
| 575 |
+
length = super_len(body)
|
| 576 |
+
if length:
|
| 577 |
+
# If length exists, set it. Otherwise, we fallback
|
| 578 |
+
# to Transfer-Encoding: chunked.
|
| 579 |
+
self.headers["Content-Length"] = builtin_str(length)
|
| 580 |
+
elif (
|
| 581 |
+
self.method not in ("GET", "HEAD")
|
| 582 |
+
and self.headers.get("Content-Length") is None
|
| 583 |
+
):
|
| 584 |
+
# Set Content-Length to 0 for methods that can have a body
|
| 585 |
+
# but don't provide one. (i.e. not GET or HEAD)
|
| 586 |
+
self.headers["Content-Length"] = "0"
|
| 587 |
+
|
| 588 |
+
def prepare_auth(self, auth, url=""):
|
| 589 |
+
"""Prepares the given HTTP auth data."""
|
| 590 |
+
|
| 591 |
+
# If no Auth is explicitly provided, extract it from the URL first.
|
| 592 |
+
if auth is None:
|
| 593 |
+
url_auth = get_auth_from_url(self.url)
|
| 594 |
+
auth = url_auth if any(url_auth) else None
|
| 595 |
+
|
| 596 |
+
if auth:
|
| 597 |
+
if isinstance(auth, tuple) and len(auth) == 2:
|
| 598 |
+
# special-case basic HTTP auth
|
| 599 |
+
auth = HTTPBasicAuth(*auth)
|
| 600 |
+
|
| 601 |
+
# Allow auth to make its changes.
|
| 602 |
+
r = auth(self)
|
| 603 |
+
|
| 604 |
+
# Update self to reflect the auth changes.
|
| 605 |
+
self.__dict__.update(r.__dict__)
|
| 606 |
+
|
| 607 |
+
# Recompute Content-Length
|
| 608 |
+
self.prepare_content_length(self.body)
|
| 609 |
+
|
| 610 |
+
def prepare_cookies(self, cookies):
|
| 611 |
+
"""Prepares the given HTTP cookie data.
|
| 612 |
+
|
| 613 |
+
This function eventually generates a ``Cookie`` header from the
|
| 614 |
+
given cookies using cookielib. Due to cookielib's design, the header
|
| 615 |
+
will not be regenerated if it already exists, meaning this function
|
| 616 |
+
can only be called once for the life of the
|
| 617 |
+
:class:`PreparedRequest <PreparedRequest>` object. Any subsequent calls
|
| 618 |
+
to ``prepare_cookies`` will have no actual effect, unless the "Cookie"
|
| 619 |
+
header is removed beforehand.
|
| 620 |
+
"""
|
| 621 |
+
if isinstance(cookies, cookielib.CookieJar):
|
| 622 |
+
self._cookies = cookies
|
| 623 |
+
else:
|
| 624 |
+
self._cookies = cookiejar_from_dict(cookies)
|
| 625 |
+
|
| 626 |
+
cookie_header = get_cookie_header(self._cookies, self)
|
| 627 |
+
if cookie_header is not None:
|
| 628 |
+
self.headers["Cookie"] = cookie_header
|
| 629 |
+
|
| 630 |
+
def prepare_hooks(self, hooks):
|
| 631 |
+
"""Prepares the given hooks."""
|
| 632 |
+
# hooks can be passed as None to the prepare method and to this
|
| 633 |
+
# method. To prevent iterating over None, simply use an empty list
|
| 634 |
+
# if hooks is False-y
|
| 635 |
+
hooks = hooks or []
|
| 636 |
+
for event in hooks:
|
| 637 |
+
self.register_hook(event, hooks[event])
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
class Response:
|
| 641 |
+
"""The :class:`Response <Response>` object, which contains a
|
| 642 |
+
server's response to an HTTP request.
|
| 643 |
+
"""
|
| 644 |
+
|
| 645 |
+
__attrs__ = [
|
| 646 |
+
"_content",
|
| 647 |
+
"status_code",
|
| 648 |
+
"headers",
|
| 649 |
+
"url",
|
| 650 |
+
"history",
|
| 651 |
+
"encoding",
|
| 652 |
+
"reason",
|
| 653 |
+
"cookies",
|
| 654 |
+
"elapsed",
|
| 655 |
+
"request",
|
| 656 |
+
]
|
| 657 |
+
|
| 658 |
+
def __init__(self):
|
| 659 |
+
self._content = False
|
| 660 |
+
self._content_consumed = False
|
| 661 |
+
self._next = None
|
| 662 |
+
|
| 663 |
+
#: Integer Code of responded HTTP Status, e.g. 404 or 200.
|
| 664 |
+
self.status_code = None
|
| 665 |
+
|
| 666 |
+
#: Case-insensitive Dictionary of Response Headers.
|
| 667 |
+
#: For example, ``headers['content-encoding']`` will return the
|
| 668 |
+
#: value of a ``'Content-Encoding'`` response header.
|
| 669 |
+
self.headers = CaseInsensitiveDict()
|
| 670 |
+
|
| 671 |
+
#: File-like object representation of response (for advanced usage).
|
| 672 |
+
#: Use of ``raw`` requires that ``stream=True`` be set on the request.
|
| 673 |
+
#: This requirement does not apply for use internally to Requests.
|
| 674 |
+
self.raw = None
|
| 675 |
+
|
| 676 |
+
#: Final URL location of Response.
|
| 677 |
+
self.url = None
|
| 678 |
+
|
| 679 |
+
#: Encoding to decode with when accessing r.text.
|
| 680 |
+
self.encoding = None
|
| 681 |
+
|
| 682 |
+
#: A list of :class:`Response <Response>` objects from
|
| 683 |
+
#: the history of the Request. Any redirect responses will end
|
| 684 |
+
#: up here. The list is sorted from the oldest to the most recent request.
|
| 685 |
+
self.history = []
|
| 686 |
+
|
| 687 |
+
#: Textual reason of responded HTTP Status, e.g. "Not Found" or "OK".
|
| 688 |
+
self.reason = None
|
| 689 |
+
|
| 690 |
+
#: A CookieJar of Cookies the server sent back.
|
| 691 |
+
self.cookies = cookiejar_from_dict({})
|
| 692 |
+
|
| 693 |
+
#: The amount of time elapsed between sending the request
|
| 694 |
+
#: and the arrival of the response (as a timedelta).
|
| 695 |
+
#: This property specifically measures the time taken between sending
|
| 696 |
+
#: the first byte of the request and finishing parsing the headers. It
|
| 697 |
+
#: is therefore unaffected by consuming the response content or the
|
| 698 |
+
#: value of the ``stream`` keyword argument.
|
| 699 |
+
self.elapsed = datetime.timedelta(0)
|
| 700 |
+
|
| 701 |
+
#: The :class:`PreparedRequest <PreparedRequest>` object to which this
|
| 702 |
+
#: is a response.
|
| 703 |
+
self.request = None
|
| 704 |
+
|
| 705 |
+
def __enter__(self):
|
| 706 |
+
return self
|
| 707 |
+
|
| 708 |
+
def __exit__(self, *args):
|
| 709 |
+
self.close()
|
| 710 |
+
|
| 711 |
+
def __getstate__(self):
|
| 712 |
+
# Consume everything; accessing the content attribute makes
|
| 713 |
+
# sure the content has been fully read.
|
| 714 |
+
if not self._content_consumed:
|
| 715 |
+
self.content
|
| 716 |
+
|
| 717 |
+
return {attr: getattr(self, attr, None) for attr in self.__attrs__}
|
| 718 |
+
|
| 719 |
+
def __setstate__(self, state):
|
| 720 |
+
for name, value in state.items():
|
| 721 |
+
setattr(self, name, value)
|
| 722 |
+
|
| 723 |
+
# pickled objects do not have .raw
|
| 724 |
+
setattr(self, "_content_consumed", True)
|
| 725 |
+
setattr(self, "raw", None)
|
| 726 |
+
|
| 727 |
+
def __repr__(self):
|
| 728 |
+
return f"<Response [{self.status_code}]>"
|
| 729 |
+
|
| 730 |
+
def __bool__(self):
|
| 731 |
+
"""Returns True if :attr:`status_code` is less than 400.
|
| 732 |
+
|
| 733 |
+
This attribute checks if the status code of the response is between
|
| 734 |
+
400 and 600 to see if there was a client error or a server error. If
|
| 735 |
+
the status code, is between 200 and 400, this will return True. This
|
| 736 |
+
is **not** a check to see if the response code is ``200 OK``.
|
| 737 |
+
"""
|
| 738 |
+
return self.ok
|
| 739 |
+
|
| 740 |
+
def __nonzero__(self):
|
| 741 |
+
"""Returns True if :attr:`status_code` is less than 400.
|
| 742 |
+
|
| 743 |
+
This attribute checks if the status code of the response is between
|
| 744 |
+
400 and 600 to see if there was a client error or a server error. If
|
| 745 |
+
the status code, is between 200 and 400, this will return True. This
|
| 746 |
+
is **not** a check to see if the response code is ``200 OK``.
|
| 747 |
+
"""
|
| 748 |
+
return self.ok
|
| 749 |
+
|
| 750 |
+
def __iter__(self):
|
| 751 |
+
"""Allows you to use a response as an iterator."""
|
| 752 |
+
return self.iter_content(128)
|
| 753 |
+
|
| 754 |
+
@property
|
| 755 |
+
def ok(self):
|
| 756 |
+
"""Returns True if :attr:`status_code` is less than 400, False if not.
|
| 757 |
+
|
| 758 |
+
This attribute checks if the status code of the response is between
|
| 759 |
+
400 and 600 to see if there was a client error or a server error. If
|
| 760 |
+
the status code is between 200 and 400, this will return True. This
|
| 761 |
+
is **not** a check to see if the response code is ``200 OK``.
|
| 762 |
+
"""
|
| 763 |
+
try:
|
| 764 |
+
self.raise_for_status()
|
| 765 |
+
except HTTPError:
|
| 766 |
+
return False
|
| 767 |
+
return True
|
| 768 |
+
|
| 769 |
+
@property
|
| 770 |
+
def is_redirect(self):
|
| 771 |
+
"""True if this Response is a well-formed HTTP redirect that could have
|
| 772 |
+
been processed automatically (by :meth:`Session.resolve_redirects`).
|
| 773 |
+
"""
|
| 774 |
+
return "location" in self.headers and self.status_code in REDIRECT_STATI
|
| 775 |
+
|
| 776 |
+
@property
|
| 777 |
+
def is_permanent_redirect(self):
|
| 778 |
+
"""True if this Response one of the permanent versions of redirect."""
|
| 779 |
+
return "location" in self.headers and self.status_code in (
|
| 780 |
+
codes.moved_permanently,
|
| 781 |
+
codes.permanent_redirect,
|
| 782 |
+
)
|
| 783 |
+
|
| 784 |
+
@property
|
| 785 |
+
def next(self):
|
| 786 |
+
"""Returns a PreparedRequest for the next request in a redirect chain, if there is one."""
|
| 787 |
+
return self._next
|
| 788 |
+
|
| 789 |
+
@property
|
| 790 |
+
def apparent_encoding(self):
|
| 791 |
+
"""The apparent encoding, provided by the charset_normalizer or chardet libraries."""
|
| 792 |
+
if chardet is not None:
|
| 793 |
+
return chardet.detect(self.content)["encoding"]
|
| 794 |
+
else:
|
| 795 |
+
# If no character detection library is available, we'll fall back
|
| 796 |
+
# to a standard Python utf-8 str.
|
| 797 |
+
return "utf-8"
|
| 798 |
+
|
| 799 |
+
def iter_content(self, chunk_size=1, decode_unicode=False):
|
| 800 |
+
"""Iterates over the response data. When stream=True is set on the
|
| 801 |
+
request, this avoids reading the content at once into memory for
|
| 802 |
+
large responses. The chunk size is the number of bytes it should
|
| 803 |
+
read into memory. This is not necessarily the length of each item
|
| 804 |
+
returned as decoding can take place.
|
| 805 |
+
|
| 806 |
+
chunk_size must be of type int or None. A value of None will
|
| 807 |
+
function differently depending on the value of `stream`.
|
| 808 |
+
stream=True will read data as it arrives in whatever size the
|
| 809 |
+
chunks are received. If stream=False, data is returned as
|
| 810 |
+
a single chunk.
|
| 811 |
+
|
| 812 |
+
If decode_unicode is True, content will be decoded using the best
|
| 813 |
+
available encoding based on the response.
|
| 814 |
+
"""
|
| 815 |
+
|
| 816 |
+
def generate():
|
| 817 |
+
# Special case for urllib3.
|
| 818 |
+
if hasattr(self.raw, "stream"):
|
| 819 |
+
try:
|
| 820 |
+
yield from self.raw.stream(chunk_size, decode_content=True)
|
| 821 |
+
except ProtocolError as e:
|
| 822 |
+
raise ChunkedEncodingError(e)
|
| 823 |
+
except DecodeError as e:
|
| 824 |
+
raise ContentDecodingError(e)
|
| 825 |
+
except ReadTimeoutError as e:
|
| 826 |
+
raise ConnectionError(e)
|
| 827 |
+
except SSLError as e:
|
| 828 |
+
raise RequestsSSLError(e)
|
| 829 |
+
else:
|
| 830 |
+
# Standard file-like object.
|
| 831 |
+
while True:
|
| 832 |
+
chunk = self.raw.read(chunk_size)
|
| 833 |
+
if not chunk:
|
| 834 |
+
break
|
| 835 |
+
yield chunk
|
| 836 |
+
|
| 837 |
+
self._content_consumed = True
|
| 838 |
+
|
| 839 |
+
if self._content_consumed and isinstance(self._content, bool):
|
| 840 |
+
raise StreamConsumedError()
|
| 841 |
+
elif chunk_size is not None and not isinstance(chunk_size, int):
|
| 842 |
+
raise TypeError(
|
| 843 |
+
f"chunk_size must be an int, it is instead a {type(chunk_size)}."
|
| 844 |
+
)
|
| 845 |
+
# simulate reading small chunks of the content
|
| 846 |
+
reused_chunks = iter_slices(self._content, chunk_size)
|
| 847 |
+
|
| 848 |
+
stream_chunks = generate()
|
| 849 |
+
|
| 850 |
+
chunks = reused_chunks if self._content_consumed else stream_chunks
|
| 851 |
+
|
| 852 |
+
if decode_unicode:
|
| 853 |
+
chunks = stream_decode_response_unicode(chunks, self)
|
| 854 |
+
|
| 855 |
+
return chunks
|
| 856 |
+
|
| 857 |
+
def iter_lines(
|
| 858 |
+
self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None
|
| 859 |
+
):
|
| 860 |
+
"""Iterates over the response data, one line at a time. When
|
| 861 |
+
stream=True is set on the request, this avoids reading the
|
| 862 |
+
content at once into memory for large responses.
|
| 863 |
+
|
| 864 |
+
.. note:: This method is not reentrant safe.
|
| 865 |
+
"""
|
| 866 |
+
|
| 867 |
+
pending = None
|
| 868 |
+
|
| 869 |
+
for chunk in self.iter_content(
|
| 870 |
+
chunk_size=chunk_size, decode_unicode=decode_unicode
|
| 871 |
+
):
|
| 872 |
+
if pending is not None:
|
| 873 |
+
chunk = pending + chunk
|
| 874 |
+
|
| 875 |
+
if delimiter:
|
| 876 |
+
lines = chunk.split(delimiter)
|
| 877 |
+
else:
|
| 878 |
+
lines = chunk.splitlines()
|
| 879 |
+
|
| 880 |
+
if lines and lines[-1] and chunk and lines[-1][-1] == chunk[-1]:
|
| 881 |
+
pending = lines.pop()
|
| 882 |
+
else:
|
| 883 |
+
pending = None
|
| 884 |
+
|
| 885 |
+
yield from lines
|
| 886 |
+
|
| 887 |
+
if pending is not None:
|
| 888 |
+
yield pending
|
| 889 |
+
|
| 890 |
+
@property
|
| 891 |
+
def content(self):
|
| 892 |
+
"""Content of the response, in bytes."""
|
| 893 |
+
|
| 894 |
+
if self._content is False:
|
| 895 |
+
# Read the contents.
|
| 896 |
+
if self._content_consumed:
|
| 897 |
+
raise RuntimeError("The content for this response was already consumed")
|
| 898 |
+
|
| 899 |
+
if self.status_code == 0 or self.raw is None:
|
| 900 |
+
self._content = None
|
| 901 |
+
else:
|
| 902 |
+
self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
|
| 903 |
+
|
| 904 |
+
self._content_consumed = True
|
| 905 |
+
# don't need to release the connection; that's been handled by urllib3
|
| 906 |
+
# since we exhausted the data.
|
| 907 |
+
return self._content
|
| 908 |
+
|
| 909 |
+
@property
|
| 910 |
+
def text(self):
|
| 911 |
+
"""Content of the response, in unicode.
|
| 912 |
+
|
| 913 |
+
If Response.encoding is None, encoding will be guessed using
|
| 914 |
+
``charset_normalizer`` or ``chardet``.
|
| 915 |
+
|
| 916 |
+
The encoding of the response content is determined based solely on HTTP
|
| 917 |
+
headers, following RFC 2616 to the letter. If you can take advantage of
|
| 918 |
+
non-HTTP knowledge to make a better guess at the encoding, you should
|
| 919 |
+
set ``r.encoding`` appropriately before accessing this property.
|
| 920 |
+
"""
|
| 921 |
+
|
| 922 |
+
# Try charset from content-type
|
| 923 |
+
content = None
|
| 924 |
+
encoding = self.encoding
|
| 925 |
+
|
| 926 |
+
if not self.content:
|
| 927 |
+
return ""
|
| 928 |
+
|
| 929 |
+
# Fallback to auto-detected encoding.
|
| 930 |
+
if self.encoding is None:
|
| 931 |
+
encoding = self.apparent_encoding
|
| 932 |
+
|
| 933 |
+
# Decode unicode from given encoding.
|
| 934 |
+
try:
|
| 935 |
+
content = str(self.content, encoding, errors="replace")
|
| 936 |
+
except (LookupError, TypeError):
|
| 937 |
+
# A LookupError is raised if the encoding was not found which could
|
| 938 |
+
# indicate a misspelling or similar mistake.
|
| 939 |
+
#
|
| 940 |
+
# A TypeError can be raised if encoding is None
|
| 941 |
+
#
|
| 942 |
+
# So we try blindly encoding.
|
| 943 |
+
content = str(self.content, errors="replace")
|
| 944 |
+
|
| 945 |
+
return content
|
| 946 |
+
|
| 947 |
+
def json(self, **kwargs):
|
| 948 |
+
r"""Returns the json-encoded content of a response, if any.
|
| 949 |
+
|
| 950 |
+
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
|
| 951 |
+
:raises requests.exceptions.JSONDecodeError: If the response body does not
|
| 952 |
+
contain valid json.
|
| 953 |
+
"""
|
| 954 |
+
|
| 955 |
+
if not self.encoding and self.content and len(self.content) > 3:
|
| 956 |
+
# No encoding set. JSON RFC 4627 section 3 states we should expect
|
| 957 |
+
# UTF-8, -16 or -32. Detect which one to use; If the detection or
|
| 958 |
+
# decoding fails, fall back to `self.text` (using charset_normalizer to make
|
| 959 |
+
# a best guess).
|
| 960 |
+
encoding = guess_json_utf(self.content)
|
| 961 |
+
if encoding is not None:
|
| 962 |
+
try:
|
| 963 |
+
return complexjson.loads(self.content.decode(encoding), **kwargs)
|
| 964 |
+
except UnicodeDecodeError:
|
| 965 |
+
# Wrong UTF codec detected; usually because it's not UTF-8
|
| 966 |
+
# but some other 8-bit codec. This is an RFC violation,
|
| 967 |
+
# and the server didn't bother to tell us what codec *was*
|
| 968 |
+
# used.
|
| 969 |
+
pass
|
| 970 |
+
except JSONDecodeError as e:
|
| 971 |
+
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
|
| 972 |
+
|
| 973 |
+
try:
|
| 974 |
+
return complexjson.loads(self.text, **kwargs)
|
| 975 |
+
except JSONDecodeError as e:
|
| 976 |
+
# Catch JSON-related errors and raise as requests.JSONDecodeError
|
| 977 |
+
# This aliases json.JSONDecodeError and simplejson.JSONDecodeError
|
| 978 |
+
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
|
| 979 |
+
|
| 980 |
+
@property
|
| 981 |
+
def links(self):
|
| 982 |
+
"""Returns the parsed header links of the response, if any."""
|
| 983 |
+
|
| 984 |
+
header = self.headers.get("link")
|
| 985 |
+
|
| 986 |
+
resolved_links = {}
|
| 987 |
+
|
| 988 |
+
if header:
|
| 989 |
+
links = parse_header_links(header)
|
| 990 |
+
|
| 991 |
+
for link in links:
|
| 992 |
+
key = link.get("rel") or link.get("url")
|
| 993 |
+
resolved_links[key] = link
|
| 994 |
+
|
| 995 |
+
return resolved_links
|
| 996 |
+
|
| 997 |
+
def raise_for_status(self):
|
| 998 |
+
"""Raises :class:`HTTPError`, if one occurred."""
|
| 999 |
+
|
| 1000 |
+
http_error_msg = ""
|
| 1001 |
+
if isinstance(self.reason, bytes):
|
| 1002 |
+
# We attempt to decode utf-8 first because some servers
|
| 1003 |
+
# choose to localize their reason strings. If the string
|
| 1004 |
+
# isn't utf-8, we fall back to iso-8859-1 for all other
|
| 1005 |
+
# encodings. (See PR #3538)
|
| 1006 |
+
try:
|
| 1007 |
+
reason = self.reason.decode("utf-8")
|
| 1008 |
+
except UnicodeDecodeError:
|
| 1009 |
+
reason = self.reason.decode("iso-8859-1")
|
| 1010 |
+
else:
|
| 1011 |
+
reason = self.reason
|
| 1012 |
+
|
| 1013 |
+
if 400 <= self.status_code < 500:
|
| 1014 |
+
http_error_msg = (
|
| 1015 |
+
f"{self.status_code} Client Error: {reason} for url: {self.url}"
|
| 1016 |
+
)
|
| 1017 |
+
|
| 1018 |
+
elif 500 <= self.status_code < 600:
|
| 1019 |
+
http_error_msg = (
|
| 1020 |
+
f"{self.status_code} Server Error: {reason} for url: {self.url}"
|
| 1021 |
+
)
|
| 1022 |
+
|
| 1023 |
+
if http_error_msg:
|
| 1024 |
+
raise HTTPError(http_error_msg, response=self)
|
| 1025 |
+
|
| 1026 |
+
def close(self):
|
| 1027 |
+
"""Releases the connection back to the pool. Once this method has been
|
| 1028 |
+
called the underlying ``raw`` object must not be accessed again.
|
| 1029 |
+
|
| 1030 |
+
*Note: Should not normally need to be called explicitly.*
|
| 1031 |
+
"""
|
| 1032 |
+
if not self._content_consumed:
|
| 1033 |
+
self.raw.close()
|
| 1034 |
+
|
| 1035 |
+
release_conn = getattr(self.raw, "release_conn", None)
|
| 1036 |
+
if release_conn is not None:
|
| 1037 |
+
release_conn()
|
wemm/lib/python3.10/site-packages/pip/_vendor/requests/structures.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
requests.structures
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Data structures that power Requests.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from collections import OrderedDict
|
| 9 |
+
|
| 10 |
+
from .compat import Mapping, MutableMapping
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class CaseInsensitiveDict(MutableMapping):
|
| 14 |
+
"""A case-insensitive ``dict``-like object.
|
| 15 |
+
|
| 16 |
+
Implements all methods and operations of
|
| 17 |
+
``MutableMapping`` as well as dict's ``copy``. Also
|
| 18 |
+
provides ``lower_items``.
|
| 19 |
+
|
| 20 |
+
All keys are expected to be strings. The structure remembers the
|
| 21 |
+
case of the last key to be set, and ``iter(instance)``,
|
| 22 |
+
``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``
|
| 23 |
+
will contain case-sensitive keys. However, querying and contains
|
| 24 |
+
testing is case insensitive::
|
| 25 |
+
|
| 26 |
+
cid = CaseInsensitiveDict()
|
| 27 |
+
cid['Accept'] = 'application/json'
|
| 28 |
+
cid['aCCEPT'] == 'application/json' # True
|
| 29 |
+
list(cid) == ['Accept'] # True
|
| 30 |
+
|
| 31 |
+
For example, ``headers['content-encoding']`` will return the
|
| 32 |
+
value of a ``'Content-Encoding'`` response header, regardless
|
| 33 |
+
of how the header name was originally stored.
|
| 34 |
+
|
| 35 |
+
If the constructor, ``.update``, or equality comparison
|
| 36 |
+
operations are given keys that have equal ``.lower()``s, the
|
| 37 |
+
behavior is undefined.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
def __init__(self, data=None, **kwargs):
|
| 41 |
+
self._store = OrderedDict()
|
| 42 |
+
if data is None:
|
| 43 |
+
data = {}
|
| 44 |
+
self.update(data, **kwargs)
|
| 45 |
+
|
| 46 |
+
def __setitem__(self, key, value):
|
| 47 |
+
# Use the lowercased key for lookups, but store the actual
|
| 48 |
+
# key alongside the value.
|
| 49 |
+
self._store[key.lower()] = (key, value)
|
| 50 |
+
|
| 51 |
+
def __getitem__(self, key):
|
| 52 |
+
return self._store[key.lower()][1]
|
| 53 |
+
|
| 54 |
+
def __delitem__(self, key):
|
| 55 |
+
del self._store[key.lower()]
|
| 56 |
+
|
| 57 |
+
def __iter__(self):
|
| 58 |
+
return (casedkey for casedkey, mappedvalue in self._store.values())
|
| 59 |
+
|
| 60 |
+
def __len__(self):
|
| 61 |
+
return len(self._store)
|
| 62 |
+
|
| 63 |
+
def lower_items(self):
|
| 64 |
+
"""Like iteritems(), but with all lowercase keys."""
|
| 65 |
+
return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items())
|
| 66 |
+
|
| 67 |
+
def __eq__(self, other):
|
| 68 |
+
if isinstance(other, Mapping):
|
| 69 |
+
other = CaseInsensitiveDict(other)
|
| 70 |
+
else:
|
| 71 |
+
return NotImplemented
|
| 72 |
+
# Compare insensitively
|
| 73 |
+
return dict(self.lower_items()) == dict(other.lower_items())
|
| 74 |
+
|
| 75 |
+
# Copy is required
|
| 76 |
+
def copy(self):
|
| 77 |
+
return CaseInsensitiveDict(self._store.values())
|
| 78 |
+
|
| 79 |
+
def __repr__(self):
|
| 80 |
+
return str(dict(self.items()))
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
class LookupDict(dict):
|
| 84 |
+
"""Dictionary lookup object."""
|
| 85 |
+
|
| 86 |
+
def __init__(self, name=None):
|
| 87 |
+
self.name = name
|
| 88 |
+
super().__init__()
|
| 89 |
+
|
| 90 |
+
def __repr__(self):
|
| 91 |
+
return f"<lookup '{self.name}'>"
|
| 92 |
+
|
| 93 |
+
def __getitem__(self, key):
|
| 94 |
+
# We allow fall-through here, so values default to None
|
| 95 |
+
|
| 96 |
+
return self.__dict__.get(key, None)
|
| 97 |
+
|
| 98 |
+
def get(self, key, default=None):
|
| 99 |
+
return self.__dict__.get(key, default)
|
wemm/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-310.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b20bd5362239d00872da811ac60a47dbeae6763cddf072194ae61790d3c4a8ee
|
| 3 |
+
size 360032
|
wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Verify certificates using native system trust stores"""
|
| 2 |
+
|
| 3 |
+
import sys as _sys
|
| 4 |
+
|
| 5 |
+
if _sys.version_info < (3, 10):
|
| 6 |
+
raise ImportError("truststore requires Python 3.10 or later")
|
| 7 |
+
|
| 8 |
+
# Detect Python runtimes which don't implement SSLObject.get_unverified_chain() API
|
| 9 |
+
# This API only became public in Python 3.13 but was available in CPython and PyPy since 3.10.
|
| 10 |
+
if _sys.version_info < (3, 13):
|
| 11 |
+
try:
|
| 12 |
+
import ssl as _ssl
|
| 13 |
+
except ImportError:
|
| 14 |
+
raise ImportError("truststore requires the 'ssl' module")
|
| 15 |
+
else:
|
| 16 |
+
_sslmem = _ssl.MemoryBIO()
|
| 17 |
+
_sslobj = _ssl.create_default_context().wrap_bio(
|
| 18 |
+
_sslmem,
|
| 19 |
+
_sslmem,
|
| 20 |
+
)
|
| 21 |
+
try:
|
| 22 |
+
while not hasattr(_sslobj, "get_unverified_chain"):
|
| 23 |
+
_sslobj = _sslobj._sslobj # type: ignore[attr-defined]
|
| 24 |
+
except AttributeError:
|
| 25 |
+
raise ImportError(
|
| 26 |
+
"truststore requires peer certificate chain APIs to be available"
|
| 27 |
+
) from None
|
| 28 |
+
|
| 29 |
+
del _ssl, _sslobj, _sslmem # noqa: F821
|
| 30 |
+
|
| 31 |
+
from ._api import SSLContext, extract_from_ssl, inject_into_ssl # noqa: E402
|
| 32 |
+
|
| 33 |
+
del _api, _sys # type: ignore[name-defined] # noqa: F821
|
| 34 |
+
|
| 35 |
+
__all__ = ["SSLContext", "inject_into_ssl", "extract_from_ssl"]
|
| 36 |
+
__version__ = "0.10.0"
|
wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (947 Bytes). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__pycache__/_macos.cpython-310.pyc
ADDED
|
Binary file (10.1 kB). View file
|
|
|
wemm/lib/python3.10/site-packages/pip/_vendor/truststore/__pycache__/_windows.cpython-310.pyc
ADDED
|
Binary file (10.6 kB). View file
|
|
|