diff --git a/.gitattributes b/.gitattributes index 2570249746a9def61f9aa68608310dab01fe5df1..9395a886fe3c85b64aa7555020da1269e785b2f8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -79,3 +79,4 @@ llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow_dataset.so.1600 filter llmeval-env/lib/python3.10/site-packages/pyarrow/lib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow_substrait.so.1600 filter=lfs diff=lfs merge=lfs -text llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow_flight.so.1600 filter=lfs diff=lfs merge=lfs -text +llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow.so.1600 filter=lfs diff=lfs merge=lfs -text diff --git a/llmeval-env/lib/python3.10/site-packages/examples/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/examples/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..94aa120653395573f708113d28b7ac3462da03a9 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/examples/__pycache__/__init__.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/examples/__pycache__/basic_example.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/examples/__pycache__/basic_example.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f77e926c4f725806653453b5a8c1e80714161947 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/examples/__pycache__/basic_example.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/__init__.py b/llmeval-env/lib/python3.10/site-packages/filelock/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..006299d2188c5d642cf78cf19305e88c95ee01cb --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/__init__.py @@ -0,0 +1,52 @@ +""" +A platform independent file lock that supports the with-statement. + +.. autodata:: filelock.__version__ + :no-value: + +""" + +from __future__ import annotations + +import sys +import warnings +from typing import TYPE_CHECKING + +from ._api import AcquireReturnProxy, BaseFileLock +from ._error import Timeout +from ._soft import SoftFileLock +from ._unix import UnixFileLock, has_fcntl +from ._windows import WindowsFileLock +from .version import version + +#: version of the project as a string +__version__: str = version + + +if sys.platform == "win32": # pragma: win32 cover + _FileLock: type[BaseFileLock] = WindowsFileLock +else: # pragma: win32 no cover # noqa: PLR5501 + if has_fcntl: + _FileLock: type[BaseFileLock] = UnixFileLock + else: + _FileLock = SoftFileLock + if warnings is not None: + warnings.warn("only soft file lock is available", stacklevel=2) + +if TYPE_CHECKING: + FileLock = SoftFileLock +else: + #: Alias for the lock, which should be used for the current platform. + FileLock = _FileLock + + +__all__ = [ + "AcquireReturnProxy", + "BaseFileLock", + "FileLock", + "SoftFileLock", + "Timeout", + "UnixFileLock", + "WindowsFileLock", + "__version__", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/__pycache__/_windows.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/filelock/__pycache__/_windows.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3c8cb1a3353fc901c314fc718e5a93b7a4e8eed2 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/filelock/__pycache__/_windows.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/_api.py b/llmeval-env/lib/python3.10/site-packages/filelock/_api.py new file mode 100644 index 0000000000000000000000000000000000000000..fd87972c7e1823c9a5cf43e13352d64caec36d34 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/_api.py @@ -0,0 +1,366 @@ +from __future__ import annotations + +import contextlib +import logging +import os +import time +import warnings +from abc import ABC, abstractmethod +from dataclasses import dataclass +from threading import local +from typing import TYPE_CHECKING, Any +from weakref import WeakValueDictionary + +from ._error import Timeout + +if TYPE_CHECKING: + import sys + from types import TracebackType + + if sys.version_info >= (3, 11): # pragma: no cover (py311+) + from typing import Self + else: # pragma: no cover ( None: + self.lock = lock + + def __enter__(self) -> BaseFileLock: + return self.lock + + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, + ) -> None: + self.lock.release() + + +@dataclass +class FileLockContext: + """A dataclass which holds the context for a ``BaseFileLock`` object.""" + + # The context is held in a separate class to allow optional use of thread local storage via the + # ThreadLocalFileContext class. + + #: The path to the lock file. + lock_file: str + + #: The default timeout value. + timeout: float + + #: The mode for the lock files + mode: int + + #: Whether the lock should be blocking or not + blocking: bool + + #: The file descriptor for the *_lock_file* as it is returned by the os.open() function, not None when lock held + lock_file_fd: int | None = None + + #: The lock counter is used for implementing the nested locking mechanism. + lock_counter: int = 0 # When the lock is acquired is increased and the lock is only released, when this value is 0 + + +class ThreadLocalFileContext(FileLockContext, local): + """A thread local version of the ``FileLockContext`` class.""" + + +class BaseFileLock(ABC, contextlib.ContextDecorator): + """Abstract base class for a file lock object.""" + + _instances: WeakValueDictionary[str, BaseFileLock] + + def __new__( # noqa: PLR0913 + cls, + lock_file: str | os.PathLike[str], + timeout: float = -1, + mode: int = 0o644, + thread_local: bool = True, # noqa: ARG003, FBT001, FBT002 + *, + blocking: bool = True, # noqa: ARG003 + is_singleton: bool = False, + **kwargs: dict[str, Any], # capture remaining kwargs for subclasses # noqa: ARG003 + ) -> Self: + """Create a new lock object or if specified return the singleton instance for the lock file.""" + if not is_singleton: + return super().__new__(cls) + + instance = cls._instances.get(str(lock_file)) + if not instance: + instance = super().__new__(cls) + cls._instances[str(lock_file)] = instance + elif timeout != instance.timeout or mode != instance.mode: + msg = "Singleton lock instances cannot be initialized with differing arguments" + raise ValueError(msg) + + return instance # type: ignore[return-value] # https://github.com/python/mypy/issues/15322 + + def __init_subclass__(cls, **kwargs: dict[str, Any]) -> None: + """Setup unique state for lock subclasses.""" + super().__init_subclass__(**kwargs) + cls._instances = WeakValueDictionary() + + def __init__( # noqa: PLR0913 + self, + lock_file: str | os.PathLike[str], + timeout: float = -1, + mode: int = 0o644, + thread_local: bool = True, # noqa: FBT001, FBT002 + *, + blocking: bool = True, + is_singleton: bool = False, + ) -> None: + """ + Create a new lock object. + + :param lock_file: path to the file + :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in \ + the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it \ + to a negative value. A timeout of 0 means that there is exactly one attempt to acquire the file lock. + :param mode: file permissions for the lockfile + :param thread_local: Whether this object's internal context should be thread local or not. If this is set to \ + ``False`` then the lock will be reentrant across threads. + :param blocking: whether the lock should be blocking or not + :param is_singleton: If this is set to ``True`` then only one instance of this class will be created \ + per lock file. This is useful if you want to use the lock object for reentrant locking without needing \ + to pass the same object around. + + """ + self._is_thread_local = thread_local + self._is_singleton = is_singleton + + # Create the context. Note that external code should not work with the context directly and should instead use + # properties of this class. + kwargs: dict[str, Any] = { + "lock_file": os.fspath(lock_file), + "timeout": timeout, + "mode": mode, + "blocking": blocking, + } + self._context: FileLockContext = (ThreadLocalFileContext if thread_local else FileLockContext)(**kwargs) + + def is_thread_local(self) -> bool: + """:return: a flag indicating if this lock is thread local or not""" + return self._is_thread_local + + @property + def is_singleton(self) -> bool: + """:return: a flag indicating if this lock is singleton or not""" + return self._is_singleton + + @property + def lock_file(self) -> str: + """:return: path to the lock file""" + return self._context.lock_file + + @property + def timeout(self) -> float: + """ + :return: the default timeout value, in seconds + + .. versionadded:: 2.0.0 + """ + return self._context.timeout + + @timeout.setter + def timeout(self, value: float | str) -> None: + """ + Change the default timeout value. + + :param value: the new value, in seconds + + """ + self._context.timeout = float(value) + + @property + def blocking(self) -> bool: + """:return: whether the locking is blocking or not""" + return self._context.blocking + + @blocking.setter + def blocking(self, value: bool) -> None: + """ + Change the default blocking value. + + :param value: the new value as bool + + """ + self._context.blocking = value + + @property + def mode(self) -> int: + """:return: the file permissions for the lockfile""" + return self._context.mode + + @abstractmethod + def _acquire(self) -> None: + """If the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file.""" + raise NotImplementedError + + @abstractmethod + def _release(self) -> None: + """Releases the lock and sets self._context.lock_file_fd to None.""" + raise NotImplementedError + + @property + def is_locked(self) -> bool: + """ + + :return: A boolean indicating if the lock file is holding the lock currently. + + .. versionchanged:: 2.0.0 + + This was previously a method and is now a property. + """ + return self._context.lock_file_fd is not None + + @property + def lock_counter(self) -> int: + """:return: The number of times this lock has been acquired (but not yet released).""" + return self._context.lock_counter + + def acquire( + self, + timeout: float | None = None, + poll_interval: float = 0.05, + *, + poll_intervall: float | None = None, + blocking: bool | None = None, + ) -> AcquireReturnProxy: + """ + Try to acquire the file lock. + + :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and + if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired + :param poll_interval: interval of trying to acquire the lock file + :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead + :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the + first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired. + :raises Timeout: if fails to acquire lock within the timeout period + :return: a context object that will unlock the file when the context is exited + + .. code-block:: python + + # You can use this method in the context manager (recommended) + with lock.acquire(): + pass + + # Or use an equivalent try-finally construct: + lock.acquire() + try: + pass + finally: + lock.release() + + .. versionchanged:: 2.0.0 + + This method returns now a *proxy* object instead of *self*, + so that it can be used in a with statement without side effects. + + """ + # Use the default timeout, if no timeout is provided. + if timeout is None: + timeout = self._context.timeout + + if blocking is None: + blocking = self._context.blocking + + if poll_intervall is not None: + msg = "use poll_interval instead of poll_intervall" + warnings.warn(msg, DeprecationWarning, stacklevel=2) + poll_interval = poll_intervall + + # Increment the number right at the beginning. We can still undo it, if something fails. + self._context.lock_counter += 1 + + lock_id = id(self) + lock_filename = self.lock_file + start_time = time.perf_counter() + try: + while True: + if not self.is_locked: + _LOGGER.debug("Attempting to acquire lock %s on %s", lock_id, lock_filename) + self._acquire() + if self.is_locked: + _LOGGER.debug("Lock %s acquired on %s", lock_id, lock_filename) + break + if blocking is False: + _LOGGER.debug("Failed to immediately acquire lock %s on %s", lock_id, lock_filename) + raise Timeout(lock_filename) # noqa: TRY301 + if 0 <= timeout < time.perf_counter() - start_time: + _LOGGER.debug("Timeout on acquiring lock %s on %s", lock_id, lock_filename) + raise Timeout(lock_filename) # noqa: TRY301 + msg = "Lock %s not acquired on %s, waiting %s seconds ..." + _LOGGER.debug(msg, lock_id, lock_filename, poll_interval) + time.sleep(poll_interval) + except BaseException: # Something did go wrong, so decrement the counter. + self._context.lock_counter = max(0, self._context.lock_counter - 1) + raise + return AcquireReturnProxy(lock=self) + + def release(self, force: bool = False) -> None: # noqa: FBT001, FBT002 + """ + Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. + Also note, that the lock file itself is not automatically deleted. + + :param force: If true, the lock counter is ignored and the lock is released in every case/ + + """ + if self.is_locked: + self._context.lock_counter -= 1 + + if self._context.lock_counter == 0 or force: + lock_id, lock_filename = id(self), self.lock_file + + _LOGGER.debug("Attempting to release lock %s on %s", lock_id, lock_filename) + self._release() + self._context.lock_counter = 0 + _LOGGER.debug("Lock %s released on %s", lock_id, lock_filename) + + def __enter__(self) -> Self: + """ + Acquire the lock. + + :return: the lock object + + """ + self.acquire() + return self + + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, + ) -> None: + """ + Release the lock. + + :param exc_type: the exception type if raised + :param exc_value: the exception value if raised + :param traceback: the exception traceback if raised + + """ + self.release() + + def __del__(self) -> None: + """Called when the lock object is deleted.""" + self.release(force=True) + + +__all__ = [ + "AcquireReturnProxy", + "BaseFileLock", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/_error.py b/llmeval-env/lib/python3.10/site-packages/filelock/_error.py new file mode 100644 index 0000000000000000000000000000000000000000..f7ff08c0f508ad7077eb6ed1990898840c952b3a --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/_error.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from typing import Any + + +class Timeout(TimeoutError): # noqa: N818 + """Raised when the lock could not be acquired in *timeout* seconds.""" + + def __init__(self, lock_file: str) -> None: + super().__init__() + self._lock_file = lock_file + + def __reduce__(self) -> str | tuple[Any, ...]: + return self.__class__, (self._lock_file,) # Properly pickle the exception + + def __str__(self) -> str: + return f"The file lock '{self._lock_file}' could not be acquired." + + def __repr__(self) -> str: + return f"{self.__class__.__name__}({self.lock_file!r})" + + @property + def lock_file(self) -> str: + """:return: The path of the file lock.""" + return self._lock_file + + +__all__ = [ + "Timeout", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/_soft.py b/llmeval-env/lib/python3.10/site-packages/filelock/_soft.py new file mode 100644 index 0000000000000000000000000000000000000000..28c67f74cc82b8f55e47afd6a71972cc1fb95eb6 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/_soft.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +import os +import sys +from contextlib import suppress +from errno import EACCES, EEXIST +from pathlib import Path + +from ._api import BaseFileLock +from ._util import ensure_directory_exists, raise_on_not_writable_file + + +class SoftFileLock(BaseFileLock): + """Simply watches the existence of the lock file.""" + + def _acquire(self) -> None: + raise_on_not_writable_file(self.lock_file) + ensure_directory_exists(self.lock_file) + # first check for exists and read-only mode as the open will mask this case as EEXIST + flags = ( + os.O_WRONLY # open for writing only + | os.O_CREAT + | os.O_EXCL # together with above raise EEXIST if the file specified by filename exists + | os.O_TRUNC # truncate the file to zero byte + ) + try: + file_handler = os.open(self.lock_file, flags, self._context.mode) + except OSError as exception: # re-raise unless expected exception + if not ( + exception.errno == EEXIST # lock already exist + or (exception.errno == EACCES and sys.platform == "win32") # has no access to this lock + ): # pragma: win32 no cover + raise + else: + self._context.lock_file_fd = file_handler + + def _release(self) -> None: + assert self._context.lock_file_fd is not None # noqa: S101 + os.close(self._context.lock_file_fd) # the lock file is definitely not None + self._context.lock_file_fd = None + with suppress(OSError): # the file is already deleted and that's what we want + Path(self.lock_file).unlink() + + +__all__ = [ + "SoftFileLock", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/_unix.py b/llmeval-env/lib/python3.10/site-packages/filelock/_unix.py new file mode 100644 index 0000000000000000000000000000000000000000..4ae1fbe916f95762418cd62251f91f74ba35fc8c --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/_unix.py @@ -0,0 +1,68 @@ +from __future__ import annotations + +import os +import sys +from contextlib import suppress +from errno import ENOSYS +from pathlib import Path +from typing import cast + +from ._api import BaseFileLock +from ._util import ensure_directory_exists + +#: a flag to indicate if the fcntl API is available +has_fcntl = False +if sys.platform == "win32": # pragma: win32 cover + + class UnixFileLock(BaseFileLock): + """Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.""" + + def _acquire(self) -> None: + raise NotImplementedError + + def _release(self) -> None: + raise NotImplementedError + +else: # pragma: win32 no cover + try: + import fcntl + except ImportError: + pass + else: + has_fcntl = True + + class UnixFileLock(BaseFileLock): + """Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.""" + + def _acquire(self) -> None: + ensure_directory_exists(self.lock_file) + open_flags = os.O_RDWR | os.O_TRUNC + if not Path(self.lock_file).exists(): + open_flags |= os.O_CREAT + fd = os.open(self.lock_file, open_flags, self._context.mode) + with suppress(PermissionError): # This locked is not owned by this UID + os.fchmod(fd, self._context.mode) + try: + fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + except OSError as exception: + os.close(fd) + if exception.errno == ENOSYS: # NotImplemented error + msg = "FileSystem does not appear to support flock; use SoftFileLock instead" + raise NotImplementedError(msg) from exception + else: + self._context.lock_file_fd = fd + + def _release(self) -> None: + # Do not remove the lockfile: + # https://github.com/tox-dev/py-filelock/issues/31 + # https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition + fd = cast(int, self._context.lock_file_fd) + self._context.lock_file_fd = None + fcntl.flock(fd, fcntl.LOCK_UN) + os.close(fd) + + +__all__ = [ + "UnixFileLock", + "has_fcntl", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/_util.py b/llmeval-env/lib/python3.10/site-packages/filelock/_util.py new file mode 100644 index 0000000000000000000000000000000000000000..c671e8533873948f0e1b5575ff952c722019f067 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/_util.py @@ -0,0 +1,52 @@ +from __future__ import annotations + +import os +import stat +import sys +from errno import EACCES, EISDIR +from pathlib import Path + + +def raise_on_not_writable_file(filename: str) -> None: + """ + Raise an exception if attempting to open the file for writing would fail. + + This is done so files that will never be writable can be separated from files that are writable but currently + locked. + + :param filename: file to check + :raises OSError: as if the file was opened for writing. + + """ + try: # use stat to do exists + can write to check without race condition + file_stat = os.stat(filename) # noqa: PTH116 + except OSError: + return # swallow does not exist or other errors + + if file_stat.st_mtime != 0: # if os.stat returns but modification is zero that's an invalid os.stat - ignore it + if not (file_stat.st_mode & stat.S_IWUSR): + raise PermissionError(EACCES, "Permission denied", filename) + + if stat.S_ISDIR(file_stat.st_mode): + if sys.platform == "win32": # pragma: win32 cover + # On Windows, this is PermissionError + raise PermissionError(EACCES, "Permission denied", filename) + else: # pragma: win32 no cover # noqa: RET506 + # On linux / macOS, this is IsADirectoryError + raise IsADirectoryError(EISDIR, "Is a directory", filename) + + +def ensure_directory_exists(filename: Path | str) -> None: + """ + Ensure the directory containing the file exists (create it if necessary). + + :param filename: file. + + """ + Path(filename).parent.mkdir(parents=True, exist_ok=True) + + +__all__ = [ + "ensure_directory_exists", + "raise_on_not_writable_file", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/_windows.py b/llmeval-env/lib/python3.10/site-packages/filelock/_windows.py new file mode 100644 index 0000000000000000000000000000000000000000..8db55dcbaa3e7bab091781b17ce22fde1fc239f2 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/_windows.py @@ -0,0 +1,65 @@ +from __future__ import annotations + +import os +import sys +from contextlib import suppress +from errno import EACCES +from pathlib import Path +from typing import cast + +from ._api import BaseFileLock +from ._util import ensure_directory_exists, raise_on_not_writable_file + +if sys.platform == "win32": # pragma: win32 cover + import msvcrt + + class WindowsFileLock(BaseFileLock): + """Uses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.""" + + def _acquire(self) -> None: + raise_on_not_writable_file(self.lock_file) + ensure_directory_exists(self.lock_file) + flags = ( + os.O_RDWR # open for read and write + | os.O_CREAT # create file if not exists + | os.O_TRUNC # truncate file if not empty + ) + try: + fd = os.open(self.lock_file, flags, self._context.mode) + except OSError as exception: + if exception.errno != EACCES: # has no access to this lock + raise + else: + try: + msvcrt.locking(fd, msvcrt.LK_NBLCK, 1) + except OSError as exception: + os.close(fd) # close file first + if exception.errno != EACCES: # file is already locked + raise + else: + self._context.lock_file_fd = fd + + def _release(self) -> None: + fd = cast(int, self._context.lock_file_fd) + self._context.lock_file_fd = None + msvcrt.locking(fd, msvcrt.LK_UNLCK, 1) + os.close(fd) + + with suppress(OSError): # Probably another instance of the application hat acquired the file lock. + Path(self.lock_file).unlink() + +else: # pragma: win32 no cover + + class WindowsFileLock(BaseFileLock): + """Uses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.""" + + def _acquire(self) -> None: + raise NotImplementedError + + def _release(self) -> None: + raise NotImplementedError + + +__all__ = [ + "WindowsFileLock", +] diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/py.typed b/llmeval-env/lib/python3.10/site-packages/filelock/py.typed new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/llmeval-env/lib/python3.10/site-packages/filelock/version.py b/llmeval-env/lib/python3.10/site-packages/filelock/version.py new file mode 100644 index 0000000000000000000000000000000000000000..431bd6d819548f96e0edd905de41ea7e3a78a745 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/filelock/version.py @@ -0,0 +1,16 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +TYPE_CHECKING = False +if TYPE_CHECKING: + from typing import Tuple, Union + VERSION_TUPLE = Tuple[Union[int, str], ...] +else: + VERSION_TUPLE = object + +version: str +__version__: str +__version_tuple__: VERSION_TUPLE +version_tuple: VERSION_TUPLE + +__version__ = version = '3.14.0' +__version_tuple__ = version_tuple = (3, 14, 0) diff --git a/llmeval-env/lib/python3.10/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 b/llmeval-env/lib/python3.10/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 new file mode 100644 index 0000000000000000000000000000000000000000..05e193bdd18b0edbec3774904c97407a4ff0afbe Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/numpy.libs/libquadmath-96973f99.so.0.0.0 differ diff --git a/llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow.so.1600 b/llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow.so.1600 new file mode 100644 index 0000000000000000000000000000000000000000..ea2385bc713a72eb3e99632dbd2ff0117aedb518 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/pyarrow/libarrow.so.1600 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d85a4a6d150efcee79c4cd53c88a5a31fd3f6f6efde3e7bd439cd8f4883024ae +size 67913016 diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..597df5924fe0206f6cedfb45375571a087343253 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/__init__.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/adapters.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/adapters.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..669f678561ce80a99e74398a5e0c5fc27138b2aa Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/adapters.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/certs.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/certs.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ac8282be17be186d2976ec00e77822aaa3c2444c Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/certs.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/compat.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/compat.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8f1849a466a1acbafec940b80109d640dbf13417 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/compat.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/exceptions.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/exceptions.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..724e9b4abae880d55944a3cab5ae502c5630eb05 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/exceptions.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/help.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/help.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5e869473fdbb7d6e7661d7014aece5c86c900588 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/help.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/models.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9421a83dab3a78e6d8078608edbc8933223c7116 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/models.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/status_codes.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/status_codes.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d939238beec7056443462564bdfd41464bfff8b7 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/requests/__pycache__/status_codes.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/requests/__version__.py b/llmeval-env/lib/python3.10/site-packages/requests/__version__.py new file mode 100644 index 0000000000000000000000000000000000000000..5063c3f8ee7980493efcc30c24f7e7582714aa81 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/__version__.py @@ -0,0 +1,14 @@ +# .-. .-. .-. . . .-. .-. .-. .-. +# |( |- |.| | | |- `-. | `-. +# ' ' `-' `-`.`-' `-' `-' ' `-' + +__title__ = "requests" +__description__ = "Python HTTP for Humans." +__url__ = "https://requests.readthedocs.io" +__version__ = "2.31.0" +__build__ = 0x023100 +__author__ = "Kenneth Reitz" +__author_email__ = "me@kennethreitz.org" +__license__ = "Apache 2.0" +__copyright__ = "Copyright Kenneth Reitz" +__cake__ = "\u2728 \U0001f370 \u2728" diff --git a/llmeval-env/lib/python3.10/site-packages/requests/_internal_utils.py b/llmeval-env/lib/python3.10/site-packages/requests/_internal_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..f2cf635e2937ee9b123a1498c5c5f723a6e20084 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/_internal_utils.py @@ -0,0 +1,50 @@ +""" +requests._internal_utils +~~~~~~~~~~~~~~ + +Provides utility functions that are consumed internally by Requests +which depend on extremely few external helpers (such as compat) +""" +import re + +from .compat import builtin_str + +_VALID_HEADER_NAME_RE_BYTE = re.compile(rb"^[^:\s][^:\r\n]*$") +_VALID_HEADER_NAME_RE_STR = re.compile(r"^[^:\s][^:\r\n]*$") +_VALID_HEADER_VALUE_RE_BYTE = re.compile(rb"^\S[^\r\n]*$|^$") +_VALID_HEADER_VALUE_RE_STR = re.compile(r"^\S[^\r\n]*$|^$") + +_HEADER_VALIDATORS_STR = (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR) +_HEADER_VALIDATORS_BYTE = (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE) +HEADER_VALIDATORS = { + bytes: _HEADER_VALIDATORS_BYTE, + str: _HEADER_VALIDATORS_STR, +} + + +def to_native_string(string, encoding="ascii"): + """Given a string object, regardless of type, returns a representation of + that string in the native string type, encoding and decoding where + necessary. This assumes ASCII unless told otherwise. + """ + if isinstance(string, builtin_str): + out = string + else: + out = string.decode(encoding) + + return out + + +def unicode_is_ascii(u_string): + """Determine if unicode string only contains ASCII characters. + + :param str u_string: unicode string to check. Must be unicode + and not Python 2 `str`. + :rtype: bool + """ + assert isinstance(u_string, str) + try: + u_string.encode("ascii") + return True + except UnicodeEncodeError: + return False diff --git a/llmeval-env/lib/python3.10/site-packages/requests/adapters.py b/llmeval-env/lib/python3.10/site-packages/requests/adapters.py new file mode 100644 index 0000000000000000000000000000000000000000..78e3bb6ecf920b429c4ecab62434b1e630c01707 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/adapters.py @@ -0,0 +1,538 @@ +""" +requests.adapters +~~~~~~~~~~~~~~~~~ + +This module contains the transport adapters that Requests uses to define +and maintain connections. +""" + +import os.path +import socket # noqa: F401 + +from urllib3.exceptions import ClosedPoolError, ConnectTimeoutError +from urllib3.exceptions import HTTPError as _HTTPError +from urllib3.exceptions import InvalidHeader as _InvalidHeader +from urllib3.exceptions import ( + LocationValueError, + MaxRetryError, + NewConnectionError, + ProtocolError, +) +from urllib3.exceptions import ProxyError as _ProxyError +from urllib3.exceptions import ReadTimeoutError, ResponseError +from urllib3.exceptions import SSLError as _SSLError +from urllib3.poolmanager import PoolManager, proxy_from_url +from urllib3.util import Timeout as TimeoutSauce +from urllib3.util import parse_url +from urllib3.util.retry import Retry + +from .auth import _basic_auth_str +from .compat import basestring, urlparse +from .cookies import extract_cookies_to_jar +from .exceptions import ( + ConnectionError, + ConnectTimeout, + InvalidHeader, + InvalidProxyURL, + InvalidSchema, + InvalidURL, + ProxyError, + ReadTimeout, + RetryError, + SSLError, +) +from .models import Response +from .structures import CaseInsensitiveDict +from .utils import ( + DEFAULT_CA_BUNDLE_PATH, + extract_zipped_paths, + get_auth_from_url, + get_encoding_from_headers, + prepend_scheme_if_needed, + select_proxy, + urldefragauth, +) + +try: + from urllib3.contrib.socks import SOCKSProxyManager +except ImportError: + + def SOCKSProxyManager(*args, **kwargs): + raise InvalidSchema("Missing dependencies for SOCKS support.") + + +DEFAULT_POOLBLOCK = False +DEFAULT_POOLSIZE = 10 +DEFAULT_RETRIES = 0 +DEFAULT_POOL_TIMEOUT = None + + +class BaseAdapter: + """The Base Transport Adapter""" + + def __init__(self): + super().__init__() + + def send( + self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None + ): + """Sends PreparedRequest object. Returns Response object. + + :param request: The :class:`PreparedRequest ` being sent. + :param stream: (optional) Whether to stream the request content. + :param timeout: (optional) How long to wait for the server to send + data before giving up, as a float, or a :ref:`(connect timeout, + read timeout) ` tuple. + :type timeout: float or tuple + :param verify: (optional) Either a boolean, in which case it controls whether we verify + the server's TLS certificate, or a string, in which case it must be a path + to a CA bundle to use + :param cert: (optional) Any user-provided SSL certificate to be trusted. + :param proxies: (optional) The proxies dictionary to apply to the request. + """ + raise NotImplementedError + + def close(self): + """Cleans up adapter specific items.""" + raise NotImplementedError + + +class HTTPAdapter(BaseAdapter): + """The built-in HTTP Adapter for urllib3. + + Provides a general-case interface for Requests sessions to contact HTTP and + HTTPS urls by implementing the Transport Adapter interface. This class will + usually be created by the :class:`Session ` class under the + covers. + + :param pool_connections: The number of urllib3 connection pools to cache. + :param pool_maxsize: The maximum number of connections to save in the pool. + :param max_retries: The maximum number of retries each connection + should attempt. Note, this applies only to failed DNS lookups, socket + connections and connection timeouts, never to requests where data has + made it to the server. By default, Requests does not retry failed + connections. If you need granular control over the conditions under + which we retry a request, import urllib3's ``Retry`` class and pass + that instead. + :param pool_block: Whether the connection pool should block for connections. + + Usage:: + + >>> import requests + >>> s = requests.Session() + >>> a = requests.adapters.HTTPAdapter(max_retries=3) + >>> s.mount('http://', a) + """ + + __attrs__ = [ + "max_retries", + "config", + "_pool_connections", + "_pool_maxsize", + "_pool_block", + ] + + def __init__( + self, + pool_connections=DEFAULT_POOLSIZE, + pool_maxsize=DEFAULT_POOLSIZE, + max_retries=DEFAULT_RETRIES, + pool_block=DEFAULT_POOLBLOCK, + ): + if max_retries == DEFAULT_RETRIES: + self.max_retries = Retry(0, read=False) + else: + self.max_retries = Retry.from_int(max_retries) + self.config = {} + self.proxy_manager = {} + + super().__init__() + + self._pool_connections = pool_connections + self._pool_maxsize = pool_maxsize + self._pool_block = pool_block + + self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block) + + def __getstate__(self): + return {attr: getattr(self, attr, None) for attr in self.__attrs__} + + def __setstate__(self, state): + # Can't handle by adding 'proxy_manager' to self.__attrs__ because + # self.poolmanager uses a lambda function, which isn't pickleable. + self.proxy_manager = {} + self.config = {} + + for attr, value in state.items(): + setattr(self, attr, value) + + self.init_poolmanager( + self._pool_connections, self._pool_maxsize, block=self._pool_block + ) + + def init_poolmanager( + self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs + ): + """Initializes a urllib3 PoolManager. + + This method should not be called from user code, and is only + exposed for use when subclassing the + :class:`HTTPAdapter `. + + :param connections: The number of urllib3 connection pools to cache. + :param maxsize: The maximum number of connections to save in the pool. + :param block: Block when no free connections are available. + :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager. + """ + # save these values for pickling + self._pool_connections = connections + self._pool_maxsize = maxsize + self._pool_block = block + + self.poolmanager = PoolManager( + num_pools=connections, + maxsize=maxsize, + block=block, + **pool_kwargs, + ) + + def proxy_manager_for(self, proxy, **proxy_kwargs): + """Return urllib3 ProxyManager for the given proxy. + + This method should not be called from user code, and is only + exposed for use when subclassing the + :class:`HTTPAdapter `. + + :param proxy: The proxy to return a urllib3 ProxyManager for. + :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager. + :returns: ProxyManager + :rtype: urllib3.ProxyManager + """ + if proxy in self.proxy_manager: + manager = self.proxy_manager[proxy] + elif proxy.lower().startswith("socks"): + username, password = get_auth_from_url(proxy) + manager = self.proxy_manager[proxy] = SOCKSProxyManager( + proxy, + username=username, + password=password, + num_pools=self._pool_connections, + maxsize=self._pool_maxsize, + block=self._pool_block, + **proxy_kwargs, + ) + else: + proxy_headers = self.proxy_headers(proxy) + manager = self.proxy_manager[proxy] = proxy_from_url( + proxy, + proxy_headers=proxy_headers, + num_pools=self._pool_connections, + maxsize=self._pool_maxsize, + block=self._pool_block, + **proxy_kwargs, + ) + + return manager + + def cert_verify(self, conn, url, verify, cert): + """Verify a SSL certificate. This method should not be called from user + code, and is only exposed for use when subclassing the + :class:`HTTPAdapter `. + + :param conn: The urllib3 connection object associated with the cert. + :param url: The requested URL. + :param verify: Either a boolean, in which case it controls whether we verify + the server's TLS certificate, or a string, in which case it must be a path + to a CA bundle to use + :param cert: The SSL certificate to verify. + """ + if url.lower().startswith("https") and verify: + + cert_loc = None + + # Allow self-specified cert location. + if verify is not True: + cert_loc = verify + + if not cert_loc: + cert_loc = extract_zipped_paths(DEFAULT_CA_BUNDLE_PATH) + + if not cert_loc or not os.path.exists(cert_loc): + raise OSError( + f"Could not find a suitable TLS CA certificate bundle, " + f"invalid path: {cert_loc}" + ) + + conn.cert_reqs = "CERT_REQUIRED" + + if not os.path.isdir(cert_loc): + conn.ca_certs = cert_loc + else: + conn.ca_cert_dir = cert_loc + else: + conn.cert_reqs = "CERT_NONE" + conn.ca_certs = None + conn.ca_cert_dir = None + + if cert: + if not isinstance(cert, basestring): + conn.cert_file = cert[0] + conn.key_file = cert[1] + else: + conn.cert_file = cert + conn.key_file = None + if conn.cert_file and not os.path.exists(conn.cert_file): + raise OSError( + f"Could not find the TLS certificate file, " + f"invalid path: {conn.cert_file}" + ) + if conn.key_file and not os.path.exists(conn.key_file): + raise OSError( + f"Could not find the TLS key file, invalid path: {conn.key_file}" + ) + + def build_response(self, req, resp): + """Builds a :class:`Response ` object from a urllib3 + response. This should not be called from user code, and is only exposed + for use when subclassing the + :class:`HTTPAdapter ` + + :param req: The :class:`PreparedRequest ` used to generate the response. + :param resp: The urllib3 response object. + :rtype: requests.Response + """ + response = Response() + + # Fallback to None if there's no status_code, for whatever reason. + response.status_code = getattr(resp, "status", None) + + # Make headers case-insensitive. + response.headers = CaseInsensitiveDict(getattr(resp, "headers", {})) + + # Set encoding. + response.encoding = get_encoding_from_headers(response.headers) + response.raw = resp + response.reason = response.raw.reason + + if isinstance(req.url, bytes): + response.url = req.url.decode("utf-8") + else: + response.url = req.url + + # Add new cookies from the server. + extract_cookies_to_jar(response.cookies, req, resp) + + # Give the Response some context. + response.request = req + response.connection = self + + return response + + def get_connection(self, url, proxies=None): + """Returns a urllib3 connection for the given URL. This should not be + called from user code, and is only exposed for use when subclassing the + :class:`HTTPAdapter `. + + :param url: The URL to connect to. + :param proxies: (optional) A Requests-style dictionary of proxies used on this request. + :rtype: urllib3.ConnectionPool + """ + proxy = select_proxy(url, proxies) + + if proxy: + proxy = prepend_scheme_if_needed(proxy, "http") + proxy_url = parse_url(proxy) + if not proxy_url.host: + raise InvalidProxyURL( + "Please check proxy URL. It is malformed " + "and could be missing the host." + ) + proxy_manager = self.proxy_manager_for(proxy) + conn = proxy_manager.connection_from_url(url) + else: + # Only scheme should be lower case + parsed = urlparse(url) + url = parsed.geturl() + conn = self.poolmanager.connection_from_url(url) + + return conn + + def close(self): + """Disposes of any internal state. + + Currently, this closes the PoolManager and any active ProxyManager, + which closes any pooled connections. + """ + self.poolmanager.clear() + for proxy in self.proxy_manager.values(): + proxy.clear() + + def request_url(self, request, proxies): + """Obtain the url to use when making the final request. + + If the message is being sent through a HTTP proxy, the full URL has to + be used. Otherwise, we should only use the path portion of the URL. + + This should not be called from user code, and is only exposed for use + when subclassing the + :class:`HTTPAdapter `. + + :param request: The :class:`PreparedRequest ` being sent. + :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs. + :rtype: str + """ + proxy = select_proxy(request.url, proxies) + scheme = urlparse(request.url).scheme + + is_proxied_http_request = proxy and scheme != "https" + using_socks_proxy = False + if proxy: + proxy_scheme = urlparse(proxy).scheme.lower() + using_socks_proxy = proxy_scheme.startswith("socks") + + url = request.path_url + if is_proxied_http_request and not using_socks_proxy: + url = urldefragauth(request.url) + + return url + + def add_headers(self, request, **kwargs): + """Add any headers needed by the connection. As of v2.0 this does + nothing by default, but is left for overriding by users that subclass + the :class:`HTTPAdapter `. + + This should not be called from user code, and is only exposed for use + when subclassing the + :class:`HTTPAdapter `. + + :param request: The :class:`PreparedRequest ` to add headers to. + :param kwargs: The keyword arguments from the call to send(). + """ + pass + + def proxy_headers(self, proxy): + """Returns a dictionary of the headers to add to any request sent + through a proxy. This works with urllib3 magic to ensure that they are + correctly sent to the proxy, rather than in a tunnelled request if + CONNECT is being used. + + This should not be called from user code, and is only exposed for use + when subclassing the + :class:`HTTPAdapter `. + + :param proxy: The url of the proxy being used for this request. + :rtype: dict + """ + headers = {} + username, password = get_auth_from_url(proxy) + + if username: + headers["Proxy-Authorization"] = _basic_auth_str(username, password) + + return headers + + def send( + self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None + ): + """Sends PreparedRequest object. Returns Response object. + + :param request: The :class:`PreparedRequest ` being sent. + :param stream: (optional) Whether to stream the request content. + :param timeout: (optional) How long to wait for the server to send + data before giving up, as a float, or a :ref:`(connect timeout, + read timeout) ` tuple. + :type timeout: float or tuple or urllib3 Timeout object + :param verify: (optional) Either a boolean, in which case it controls whether + we verify the server's TLS certificate, or a string, in which case it + must be a path to a CA bundle to use + :param cert: (optional) Any user-provided SSL certificate to be trusted. + :param proxies: (optional) The proxies dictionary to apply to the request. + :rtype: requests.Response + """ + + try: + conn = self.get_connection(request.url, proxies) + except LocationValueError as e: + raise InvalidURL(e, request=request) + + self.cert_verify(conn, request.url, verify, cert) + url = self.request_url(request, proxies) + self.add_headers( + request, + stream=stream, + timeout=timeout, + verify=verify, + cert=cert, + proxies=proxies, + ) + + chunked = not (request.body is None or "Content-Length" in request.headers) + + if isinstance(timeout, tuple): + try: + connect, read = timeout + timeout = TimeoutSauce(connect=connect, read=read) + except ValueError: + raise ValueError( + f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " + f"or a single float to set both timeouts to the same value." + ) + elif isinstance(timeout, TimeoutSauce): + pass + else: + timeout = TimeoutSauce(connect=timeout, read=timeout) + + try: + resp = conn.urlopen( + method=request.method, + url=url, + body=request.body, + headers=request.headers, + redirect=False, + assert_same_host=False, + preload_content=False, + decode_content=False, + retries=self.max_retries, + timeout=timeout, + chunked=chunked, + ) + + except (ProtocolError, OSError) as err: + raise ConnectionError(err, request=request) + + except MaxRetryError as e: + if isinstance(e.reason, ConnectTimeoutError): + # TODO: Remove this in 3.0.0: see #2811 + if not isinstance(e.reason, NewConnectionError): + raise ConnectTimeout(e, request=request) + + if isinstance(e.reason, ResponseError): + raise RetryError(e, request=request) + + if isinstance(e.reason, _ProxyError): + raise ProxyError(e, request=request) + + if isinstance(e.reason, _SSLError): + # This branch is for urllib3 v1.22 and later. + raise SSLError(e, request=request) + + raise ConnectionError(e, request=request) + + except ClosedPoolError as e: + raise ConnectionError(e, request=request) + + except _ProxyError as e: + raise ProxyError(e) + + except (_SSLError, _HTTPError) as e: + if isinstance(e, _SSLError): + # This branch is for urllib3 versions earlier than v1.22 + raise SSLError(e, request=request) + elif isinstance(e, ReadTimeoutError): + raise ReadTimeout(e, request=request) + elif isinstance(e, _InvalidHeader): + raise InvalidHeader(e, request=request) + else: + raise + + return self.build_response(request, resp) diff --git a/llmeval-env/lib/python3.10/site-packages/requests/api.py b/llmeval-env/lib/python3.10/site-packages/requests/api.py new file mode 100644 index 0000000000000000000000000000000000000000..cd0b3eeac3ebca7fe4a627ba5a96c1bbaf827d4f --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/api.py @@ -0,0 +1,157 @@ +""" +requests.api +~~~~~~~~~~~~ + +This module implements the Requests API. + +:copyright: (c) 2012 by Kenneth Reitz. +:license: Apache2, see LICENSE for more details. +""" + +from . import sessions + + +def request(method, url, **kwargs): + """Constructs and sends a :class:`Request `. + + :param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``. + :param url: URL for the new :class:`Request` object. + :param params: (optional) Dictionary, list of tuples or bytes to send + in the query string for the :class:`Request`. + :param data: (optional) Dictionary, list of tuples, bytes, or file-like + object to send in the body of the :class:`Request`. + :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`. + :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. + :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. + :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload. + ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')`` + or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string + defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers + to add for the file. + :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth. + :param timeout: (optional) How many seconds to wait for the server to send data + before giving up, as a float, or a :ref:`(connect timeout, read + timeout) ` tuple. + :type timeout: float or tuple + :param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``. + :type allow_redirects: bool + :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy. + :param verify: (optional) Either a boolean, in which case it controls whether we verify + the server's TLS certificate, or a string, in which case it must be a path + to a CA bundle to use. Defaults to ``True``. + :param stream: (optional) if ``False``, the response content will be immediately downloaded. + :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. + :return: :class:`Response ` object + :rtype: requests.Response + + Usage:: + + >>> import requests + >>> req = requests.request('GET', 'https://httpbin.org/get') + >>> req + + """ + + # By using the 'with' statement we are sure the session is closed, thus we + # avoid leaving sockets open which can trigger a ResourceWarning in some + # cases, and look like a memory leak in others. + with sessions.Session() as session: + return session.request(method=method, url=url, **kwargs) + + +def get(url, params=None, **kwargs): + r"""Sends a GET request. + + :param url: URL for the new :class:`Request` object. + :param params: (optional) Dictionary, list of tuples or bytes to send + in the query string for the :class:`Request`. + :param \*\*kwargs: Optional arguments that ``request`` takes. + :return: :class:`Response ` object + :rtype: requests.Response + """ + + return request("get", url, params=params, **kwargs) + + +def options(url, **kwargs): + r"""Sends an OPTIONS request. + + :param url: URL for the new :class:`Request` object. + :param \*\*kwargs: Optional arguments that ``request`` takes. + :return: :class:`Response ` object + :rtype: requests.Response + """ + + return request("options", url, **kwargs) + + +def head(url, **kwargs): + r"""Sends a HEAD request. + + :param url: URL for the new :class:`Request` object. + :param \*\*kwargs: Optional arguments that ``request`` takes. If + `allow_redirects` is not provided, it will be set to `False` (as + opposed to the default :meth:`request` behavior). + :return: :class:`Response ` object + :rtype: requests.Response + """ + + kwargs.setdefault("allow_redirects", False) + return request("head", url, **kwargs) + + +def post(url, data=None, json=None, **kwargs): + r"""Sends a POST request. + + :param url: URL for the new :class:`Request` object. + :param data: (optional) Dictionary, list of tuples, bytes, or file-like + object to send in the body of the :class:`Request`. + :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`. + :param \*\*kwargs: Optional arguments that ``request`` takes. + :return: :class:`Response ` object + :rtype: requests.Response + """ + + return request("post", url, data=data, json=json, **kwargs) + + +def put(url, data=None, **kwargs): + r"""Sends a PUT request. + + :param url: URL for the new :class:`Request` object. + :param data: (optional) Dictionary, list of tuples, bytes, or file-like + object to send in the body of the :class:`Request`. + :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`. + :param \*\*kwargs: Optional arguments that ``request`` takes. + :return: :class:`Response ` object + :rtype: requests.Response + """ + + return request("put", url, data=data, **kwargs) + + +def patch(url, data=None, **kwargs): + r"""Sends a PATCH request. + + :param url: URL for the new :class:`Request` object. + :param data: (optional) Dictionary, list of tuples, bytes, or file-like + object to send in the body of the :class:`Request`. + :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`. + :param \*\*kwargs: Optional arguments that ``request`` takes. + :return: :class:`Response ` object + :rtype: requests.Response + """ + + return request("patch", url, data=data, **kwargs) + + +def delete(url, **kwargs): + r"""Sends a DELETE request. + + :param url: URL for the new :class:`Request` object. + :param \*\*kwargs: Optional arguments that ``request`` takes. + :return: :class:`Response ` object + :rtype: requests.Response + """ + + return request("delete", url, **kwargs) diff --git a/llmeval-env/lib/python3.10/site-packages/requests/auth.py b/llmeval-env/lib/python3.10/site-packages/requests/auth.py new file mode 100644 index 0000000000000000000000000000000000000000..9733686ddb36b826ead4f4666d42311397fa6fec --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/auth.py @@ -0,0 +1,315 @@ +""" +requests.auth +~~~~~~~~~~~~~ + +This module contains the authentication handlers for Requests. +""" + +import hashlib +import os +import re +import threading +import time +import warnings +from base64 import b64encode + +from ._internal_utils import to_native_string +from .compat import basestring, str, urlparse +from .cookies import extract_cookies_to_jar +from .utils import parse_dict_header + +CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded" +CONTENT_TYPE_MULTI_PART = "multipart/form-data" + + +def _basic_auth_str(username, password): + """Returns a Basic Auth string.""" + + # "I want us to put a big-ol' comment on top of it that + # says that this behaviour is dumb but we need to preserve + # it because people are relying on it." + # - Lukasa + # + # These are here solely to maintain backwards compatibility + # for things like ints. This will be removed in 3.0.0. + if not isinstance(username, basestring): + warnings.warn( + "Non-string usernames will no longer be supported in Requests " + "3.0.0. Please convert the object you've passed in ({!r}) to " + "a string or bytes object in the near future to avoid " + "problems.".format(username), + category=DeprecationWarning, + ) + username = str(username) + + if not isinstance(password, basestring): + warnings.warn( + "Non-string passwords will no longer be supported in Requests " + "3.0.0. Please convert the object you've passed in ({!r}) to " + "a string or bytes object in the near future to avoid " + "problems.".format(type(password)), + category=DeprecationWarning, + ) + password = str(password) + # -- End Removal -- + + if isinstance(username, str): + username = username.encode("latin1") + + if isinstance(password, str): + password = password.encode("latin1") + + authstr = "Basic " + to_native_string( + b64encode(b":".join((username, password))).strip() + ) + + return authstr + + +class AuthBase: + """Base class that all auth implementations derive from""" + + def __call__(self, r): + raise NotImplementedError("Auth hooks must be callable.") + + +class HTTPBasicAuth(AuthBase): + """Attaches HTTP Basic Authentication to the given Request object.""" + + def __init__(self, username, password): + self.username = username + self.password = password + + def __eq__(self, other): + return all( + [ + self.username == getattr(other, "username", None), + self.password == getattr(other, "password", None), + ] + ) + + def __ne__(self, other): + return not self == other + + def __call__(self, r): + r.headers["Authorization"] = _basic_auth_str(self.username, self.password) + return r + + +class HTTPProxyAuth(HTTPBasicAuth): + """Attaches HTTP Proxy Authentication to a given Request object.""" + + def __call__(self, r): + r.headers["Proxy-Authorization"] = _basic_auth_str(self.username, self.password) + return r + + +class HTTPDigestAuth(AuthBase): + """Attaches HTTP Digest Authentication to the given Request object.""" + + def __init__(self, username, password): + self.username = username + self.password = password + # Keep state in per-thread local storage + self._thread_local = threading.local() + + def init_per_thread_state(self): + # Ensure state is initialized just once per-thread + if not hasattr(self._thread_local, "init"): + self._thread_local.init = True + self._thread_local.last_nonce = "" + self._thread_local.nonce_count = 0 + self._thread_local.chal = {} + self._thread_local.pos = None + self._thread_local.num_401_calls = None + + def build_digest_header(self, method, url): + """ + :rtype: str + """ + + realm = self._thread_local.chal["realm"] + nonce = self._thread_local.chal["nonce"] + qop = self._thread_local.chal.get("qop") + algorithm = self._thread_local.chal.get("algorithm") + opaque = self._thread_local.chal.get("opaque") + hash_utf8 = None + + if algorithm is None: + _algorithm = "MD5" + else: + _algorithm = algorithm.upper() + # lambdas assume digest modules are imported at the top level + if _algorithm == "MD5" or _algorithm == "MD5-SESS": + + def md5_utf8(x): + if isinstance(x, str): + x = x.encode("utf-8") + return hashlib.md5(x).hexdigest() + + hash_utf8 = md5_utf8 + elif _algorithm == "SHA": + + def sha_utf8(x): + if isinstance(x, str): + x = x.encode("utf-8") + return hashlib.sha1(x).hexdigest() + + hash_utf8 = sha_utf8 + elif _algorithm == "SHA-256": + + def sha256_utf8(x): + if isinstance(x, str): + x = x.encode("utf-8") + return hashlib.sha256(x).hexdigest() + + hash_utf8 = sha256_utf8 + elif _algorithm == "SHA-512": + + def sha512_utf8(x): + if isinstance(x, str): + x = x.encode("utf-8") + return hashlib.sha512(x).hexdigest() + + hash_utf8 = sha512_utf8 + + KD = lambda s, d: hash_utf8(f"{s}:{d}") # noqa:E731 + + if hash_utf8 is None: + return None + + # XXX not implemented yet + entdig = None + p_parsed = urlparse(url) + #: path is request-uri defined in RFC 2616 which should not be empty + path = p_parsed.path or "/" + if p_parsed.query: + path += f"?{p_parsed.query}" + + A1 = f"{self.username}:{realm}:{self.password}" + A2 = f"{method}:{path}" + + HA1 = hash_utf8(A1) + HA2 = hash_utf8(A2) + + if nonce == self._thread_local.last_nonce: + self._thread_local.nonce_count += 1 + else: + self._thread_local.nonce_count = 1 + ncvalue = f"{self._thread_local.nonce_count:08x}" + s = str(self._thread_local.nonce_count).encode("utf-8") + s += nonce.encode("utf-8") + s += time.ctime().encode("utf-8") + s += os.urandom(8) + + cnonce = hashlib.sha1(s).hexdigest()[:16] + if _algorithm == "MD5-SESS": + HA1 = hash_utf8(f"{HA1}:{nonce}:{cnonce}") + + if not qop: + respdig = KD(HA1, f"{nonce}:{HA2}") + elif qop == "auth" or "auth" in qop.split(","): + noncebit = f"{nonce}:{ncvalue}:{cnonce}:auth:{HA2}" + respdig = KD(HA1, noncebit) + else: + # XXX handle auth-int. + return None + + self._thread_local.last_nonce = nonce + + # XXX should the partial digests be encoded too? + base = ( + f'username="{self.username}", realm="{realm}", nonce="{nonce}", ' + f'uri="{path}", response="{respdig}"' + ) + if opaque: + base += f', opaque="{opaque}"' + if algorithm: + base += f', algorithm="{algorithm}"' + if entdig: + base += f', digest="{entdig}"' + if qop: + base += f', qop="auth", nc={ncvalue}, cnonce="{cnonce}"' + + return f"Digest {base}" + + def handle_redirect(self, r, **kwargs): + """Reset num_401_calls counter on redirects.""" + if r.is_redirect: + self._thread_local.num_401_calls = 1 + + def handle_401(self, r, **kwargs): + """ + Takes the given response and tries digest-auth, if needed. + + :rtype: requests.Response + """ + + # If response is not 4xx, do not auth + # See https://github.com/psf/requests/issues/3772 + if not 400 <= r.status_code < 500: + self._thread_local.num_401_calls = 1 + return r + + if self._thread_local.pos is not None: + # Rewind the file position indicator of the body to where + # it was to resend the request. + r.request.body.seek(self._thread_local.pos) + s_auth = r.headers.get("www-authenticate", "") + + if "digest" in s_auth.lower() and self._thread_local.num_401_calls < 2: + + self._thread_local.num_401_calls += 1 + pat = re.compile(r"digest ", flags=re.IGNORECASE) + self._thread_local.chal = parse_dict_header(pat.sub("", s_auth, count=1)) + + # Consume content and release the original connection + # to allow our new request to reuse the same one. + r.content + r.close() + prep = r.request.copy() + extract_cookies_to_jar(prep._cookies, r.request, r.raw) + prep.prepare_cookies(prep._cookies) + + prep.headers["Authorization"] = self.build_digest_header( + prep.method, prep.url + ) + _r = r.connection.send(prep, **kwargs) + _r.history.append(r) + _r.request = prep + + return _r + + self._thread_local.num_401_calls = 1 + return r + + def __call__(self, r): + # Initialize per-thread state, if needed + self.init_per_thread_state() + # If we have a saved nonce, skip the 401 + if self._thread_local.last_nonce: + r.headers["Authorization"] = self.build_digest_header(r.method, r.url) + try: + self._thread_local.pos = r.body.tell() + except AttributeError: + # In the case of HTTPDigestAuth being reused and the body of + # the previous request was a file-like object, pos has the + # file position of the previous body. Ensure it's set to + # None. + self._thread_local.pos = None + r.register_hook("response", self.handle_401) + r.register_hook("response", self.handle_redirect) + self._thread_local.num_401_calls = 1 + + return r + + def __eq__(self, other): + return all( + [ + self.username == getattr(other, "username", None), + self.password == getattr(other, "password", None), + ] + ) + + def __ne__(self, other): + return not self == other diff --git a/llmeval-env/lib/python3.10/site-packages/requests/certs.py b/llmeval-env/lib/python3.10/site-packages/requests/certs.py new file mode 100644 index 0000000000000000000000000000000000000000..be422c3e91e43bacf60ff3302688df0b28742333 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/certs.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +""" +requests.certs +~~~~~~~~~~~~~~ + +This module returns the preferred default CA certificate bundle. There is +only one — the one from the certifi package. + +If you are packaging Requests, e.g., for a Linux distribution or a managed +environment, you can change the definition of where() to return a separately +packaged CA bundle. +""" +from certifi import where + +if __name__ == "__main__": + print(where()) diff --git a/llmeval-env/lib/python3.10/site-packages/requests/compat.py b/llmeval-env/lib/python3.10/site-packages/requests/compat.py new file mode 100644 index 0000000000000000000000000000000000000000..6776163c94f3d6f61b00d329d4061d6b02afeeb9 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/compat.py @@ -0,0 +1,79 @@ +""" +requests.compat +~~~~~~~~~~~~~~~ + +This module previously handled import compatibility issues +between Python 2 and Python 3. It remains for backwards +compatibility until the next major version. +""" + +try: + import chardet +except ImportError: + import charset_normalizer as chardet + +import sys + +# ------- +# Pythons +# ------- + +# Syntax sugar. +_ver = sys.version_info + +#: Python 2.x? +is_py2 = _ver[0] == 2 + +#: Python 3.x? +is_py3 = _ver[0] == 3 + +# json/simplejson module import resolution +has_simplejson = False +try: + import simplejson as json + + has_simplejson = True +except ImportError: + import json + +if has_simplejson: + from simplejson import JSONDecodeError +else: + from json import JSONDecodeError + +# Keep OrderedDict for backwards compatibility. +from collections import OrderedDict +from collections.abc import Callable, Mapping, MutableMapping +from http import cookiejar as cookielib +from http.cookies import Morsel +from io import StringIO + +# -------------- +# Legacy Imports +# -------------- +from urllib.parse import ( + quote, + quote_plus, + unquote, + unquote_plus, + urldefrag, + urlencode, + urljoin, + urlparse, + urlsplit, + urlunparse, +) +from urllib.request import ( + getproxies, + getproxies_environment, + parse_http_list, + proxy_bypass, + proxy_bypass_environment, +) + +builtin_str = str +str = str +bytes = bytes +basestring = (str, bytes) +numeric_types = (int, float) +integer_types = (int,) diff --git a/llmeval-env/lib/python3.10/site-packages/requests/exceptions.py b/llmeval-env/lib/python3.10/site-packages/requests/exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e1cedf883d3eadcbfda91967d36b7c59b8367e76 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/exceptions.py @@ -0,0 +1,141 @@ +""" +requests.exceptions +~~~~~~~~~~~~~~~~~~~ + +This module contains the set of Requests' exceptions. +""" +from urllib3.exceptions import HTTPError as BaseHTTPError + +from .compat import JSONDecodeError as CompatJSONDecodeError + + +class RequestException(IOError): + """There was an ambiguous exception that occurred while handling your + request. + """ + + def __init__(self, *args, **kwargs): + """Initialize RequestException with `request` and `response` objects.""" + response = kwargs.pop("response", None) + self.response = response + self.request = kwargs.pop("request", None) + if response is not None and not self.request and hasattr(response, "request"): + self.request = self.response.request + super().__init__(*args, **kwargs) + + +class InvalidJSONError(RequestException): + """A JSON error occurred.""" + + +class JSONDecodeError(InvalidJSONError, CompatJSONDecodeError): + """Couldn't decode the text into json""" + + def __init__(self, *args, **kwargs): + """ + Construct the JSONDecodeError instance first with all + args. Then use it's args to construct the IOError so that + the json specific args aren't used as IOError specific args + and the error message from JSONDecodeError is preserved. + """ + CompatJSONDecodeError.__init__(self, *args) + InvalidJSONError.__init__(self, *self.args, **kwargs) + + +class HTTPError(RequestException): + """An HTTP error occurred.""" + + +class ConnectionError(RequestException): + """A Connection error occurred.""" + + +class ProxyError(ConnectionError): + """A proxy error occurred.""" + + +class SSLError(ConnectionError): + """An SSL error occurred.""" + + +class Timeout(RequestException): + """The request timed out. + + Catching this error will catch both + :exc:`~requests.exceptions.ConnectTimeout` and + :exc:`~requests.exceptions.ReadTimeout` errors. + """ + + +class ConnectTimeout(ConnectionError, Timeout): + """The request timed out while trying to connect to the remote server. + + Requests that produced this error are safe to retry. + """ + + +class ReadTimeout(Timeout): + """The server did not send any data in the allotted amount of time.""" + + +class URLRequired(RequestException): + """A valid URL is required to make a request.""" + + +class TooManyRedirects(RequestException): + """Too many redirects.""" + + +class MissingSchema(RequestException, ValueError): + """The URL scheme (e.g. http or https) is missing.""" + + +class InvalidSchema(RequestException, ValueError): + """The URL scheme provided is either invalid or unsupported.""" + + +class InvalidURL(RequestException, ValueError): + """The URL provided was somehow invalid.""" + + +class InvalidHeader(RequestException, ValueError): + """The header value provided was somehow invalid.""" + + +class InvalidProxyURL(InvalidURL): + """The proxy URL provided is invalid.""" + + +class ChunkedEncodingError(RequestException): + """The server declared chunked encoding but sent an invalid chunk.""" + + +class ContentDecodingError(RequestException, BaseHTTPError): + """Failed to decode response content.""" + + +class StreamConsumedError(RequestException, TypeError): + """The content for this response was already consumed.""" + + +class RetryError(RequestException): + """Custom retries logic failed""" + + +class UnrewindableBodyError(RequestException): + """Requests encountered an error when trying to rewind a body.""" + + +# Warnings + + +class RequestsWarning(Warning): + """Base warning for Requests.""" + + +class FileModeWarning(RequestsWarning, DeprecationWarning): + """A file was opened in text mode, but Requests determined its binary length.""" + + +class RequestsDependencyWarning(RequestsWarning): + """An imported dependency doesn't match the expected version range.""" diff --git a/llmeval-env/lib/python3.10/site-packages/requests/help.py b/llmeval-env/lib/python3.10/site-packages/requests/help.py new file mode 100644 index 0000000000000000000000000000000000000000..8fbcd6560a8fe2c8a07e3bd1441a81e0db9cb689 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/help.py @@ -0,0 +1,134 @@ +"""Module containing bug report helper(s).""" + +import json +import platform +import ssl +import sys + +import idna +import urllib3 + +from . import __version__ as requests_version + +try: + import charset_normalizer +except ImportError: + charset_normalizer = None + +try: + import chardet +except ImportError: + chardet = None + +try: + from urllib3.contrib import pyopenssl +except ImportError: + pyopenssl = None + OpenSSL = None + cryptography = None +else: + import cryptography + import OpenSSL + + +def _implementation(): + """Return a dict with the Python implementation and version. + + Provide both the name and the version of the Python implementation + currently running. For example, on CPython 3.10.3 it will return + {'name': 'CPython', 'version': '3.10.3'}. + + This function works best on CPython and PyPy: in particular, it probably + doesn't work for Jython or IronPython. Future investigation should be done + to work out the correct shape of the code for those platforms. + """ + implementation = platform.python_implementation() + + if implementation == "CPython": + implementation_version = platform.python_version() + elif implementation == "PyPy": + implementation_version = "{}.{}.{}".format( + sys.pypy_version_info.major, + sys.pypy_version_info.minor, + sys.pypy_version_info.micro, + ) + if sys.pypy_version_info.releaselevel != "final": + implementation_version = "".join( + [implementation_version, sys.pypy_version_info.releaselevel] + ) + elif implementation == "Jython": + implementation_version = platform.python_version() # Complete Guess + elif implementation == "IronPython": + implementation_version = platform.python_version() # Complete Guess + else: + implementation_version = "Unknown" + + return {"name": implementation, "version": implementation_version} + + +def info(): + """Generate information for a bug report.""" + try: + platform_info = { + "system": platform.system(), + "release": platform.release(), + } + except OSError: + platform_info = { + "system": "Unknown", + "release": "Unknown", + } + + implementation_info = _implementation() + urllib3_info = {"version": urllib3.__version__} + charset_normalizer_info = {"version": None} + chardet_info = {"version": None} + if charset_normalizer: + charset_normalizer_info = {"version": charset_normalizer.__version__} + if chardet: + chardet_info = {"version": chardet.__version__} + + pyopenssl_info = { + "version": None, + "openssl_version": "", + } + if OpenSSL: + pyopenssl_info = { + "version": OpenSSL.__version__, + "openssl_version": f"{OpenSSL.SSL.OPENSSL_VERSION_NUMBER:x}", + } + cryptography_info = { + "version": getattr(cryptography, "__version__", ""), + } + idna_info = { + "version": getattr(idna, "__version__", ""), + } + + system_ssl = ssl.OPENSSL_VERSION_NUMBER + system_ssl_info = {"version": f"{system_ssl:x}" if system_ssl is not None else ""} + + return { + "platform": platform_info, + "implementation": implementation_info, + "system_ssl": system_ssl_info, + "using_pyopenssl": pyopenssl is not None, + "using_charset_normalizer": chardet is None, + "pyOpenSSL": pyopenssl_info, + "urllib3": urllib3_info, + "chardet": chardet_info, + "charset_normalizer": charset_normalizer_info, + "cryptography": cryptography_info, + "idna": idna_info, + "requests": { + "version": requests_version, + }, + } + + +def main(): + """Pretty-print the bug information as JSON.""" + print(json.dumps(info(), sort_keys=True, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/llmeval-env/lib/python3.10/site-packages/requests/packages.py b/llmeval-env/lib/python3.10/site-packages/requests/packages.py new file mode 100644 index 0000000000000000000000000000000000000000..77c45c9e90cdf2bcd60eea3cac9c8cf56cca2c08 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/packages.py @@ -0,0 +1,28 @@ +import sys + +try: + import chardet +except ImportError: + import warnings + + import charset_normalizer as chardet + + warnings.filterwarnings("ignore", "Trying to detect", module="charset_normalizer") + +# This code exists for backwards compatibility reasons. +# I don't like it either. Just look the other way. :) + +for package in ("urllib3", "idna"): + locals()[package] = __import__(package) + # This traversal is apparently necessary such that the identities are + # preserved (requests.packages.urllib3.* is urllib3.*) + for mod in list(sys.modules): + if mod == package or mod.startswith(f"{package}."): + sys.modules[f"requests.packages.{mod}"] = sys.modules[mod] + +target = chardet.__name__ +for mod in list(sys.modules): + if mod == target or mod.startswith(f"{target}."): + target = target.replace(target, "chardet") + sys.modules[f"requests.packages.{target}"] = sys.modules[mod] +# Kinda cool, though, right? diff --git a/llmeval-env/lib/python3.10/site-packages/requests/status_codes.py b/llmeval-env/lib/python3.10/site-packages/requests/status_codes.py new file mode 100644 index 0000000000000000000000000000000000000000..4bd072be9769748a852740d037d5c63021472c9d --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/status_codes.py @@ -0,0 +1,128 @@ +r""" +The ``codes`` object defines a mapping from common names for HTTP statuses +to their numerical codes, accessible either as attributes or as dictionary +items. + +Example:: + + >>> import requests + >>> requests.codes['temporary_redirect'] + 307 + >>> requests.codes.teapot + 418 + >>> requests.codes['\o/'] + 200 + +Some codes have multiple names, and both upper- and lower-case versions of +the names are allowed. For example, ``codes.ok``, ``codes.OK``, and +``codes.okay`` all correspond to the HTTP status code 200. +""" + +from .structures import LookupDict + +_codes = { + # Informational. + 100: ("continue",), + 101: ("switching_protocols",), + 102: ("processing",), + 103: ("checkpoint",), + 122: ("uri_too_long", "request_uri_too_long"), + 200: ("ok", "okay", "all_ok", "all_okay", "all_good", "\\o/", "✓"), + 201: ("created",), + 202: ("accepted",), + 203: ("non_authoritative_info", "non_authoritative_information"), + 204: ("no_content",), + 205: ("reset_content", "reset"), + 206: ("partial_content", "partial"), + 207: ("multi_status", "multiple_status", "multi_stati", "multiple_stati"), + 208: ("already_reported",), + 226: ("im_used",), + # Redirection. + 300: ("multiple_choices",), + 301: ("moved_permanently", "moved", "\\o-"), + 302: ("found",), + 303: ("see_other", "other"), + 304: ("not_modified",), + 305: ("use_proxy",), + 306: ("switch_proxy",), + 307: ("temporary_redirect", "temporary_moved", "temporary"), + 308: ( + "permanent_redirect", + "resume_incomplete", + "resume", + ), # "resume" and "resume_incomplete" to be removed in 3.0 + # Client Error. + 400: ("bad_request", "bad"), + 401: ("unauthorized",), + 402: ("payment_required", "payment"), + 403: ("forbidden",), + 404: ("not_found", "-o-"), + 405: ("method_not_allowed", "not_allowed"), + 406: ("not_acceptable",), + 407: ("proxy_authentication_required", "proxy_auth", "proxy_authentication"), + 408: ("request_timeout", "timeout"), + 409: ("conflict",), + 410: ("gone",), + 411: ("length_required",), + 412: ("precondition_failed", "precondition"), + 413: ("request_entity_too_large",), + 414: ("request_uri_too_large",), + 415: ("unsupported_media_type", "unsupported_media", "media_type"), + 416: ( + "requested_range_not_satisfiable", + "requested_range", + "range_not_satisfiable", + ), + 417: ("expectation_failed",), + 418: ("im_a_teapot", "teapot", "i_am_a_teapot"), + 421: ("misdirected_request",), + 422: ("unprocessable_entity", "unprocessable"), + 423: ("locked",), + 424: ("failed_dependency", "dependency"), + 425: ("unordered_collection", "unordered"), + 426: ("upgrade_required", "upgrade"), + 428: ("precondition_required", "precondition"), + 429: ("too_many_requests", "too_many"), + 431: ("header_fields_too_large", "fields_too_large"), + 444: ("no_response", "none"), + 449: ("retry_with", "retry"), + 450: ("blocked_by_windows_parental_controls", "parental_controls"), + 451: ("unavailable_for_legal_reasons", "legal_reasons"), + 499: ("client_closed_request",), + # Server Error. + 500: ("internal_server_error", "server_error", "/o\\", "✗"), + 501: ("not_implemented",), + 502: ("bad_gateway",), + 503: ("service_unavailable", "unavailable"), + 504: ("gateway_timeout",), + 505: ("http_version_not_supported", "http_version"), + 506: ("variant_also_negotiates",), + 507: ("insufficient_storage",), + 509: ("bandwidth_limit_exceeded", "bandwidth"), + 510: ("not_extended",), + 511: ("network_authentication_required", "network_auth", "network_authentication"), +} + +codes = LookupDict(name="status_codes") + + +def _init(): + for code, titles in _codes.items(): + for title in titles: + setattr(codes, title, code) + if not title.startswith(("\\", "/")): + setattr(codes, title.upper(), code) + + def doc(code): + names = ", ".join(f"``{n}``" for n in _codes[code]) + return "* %d: %s" % (code, names) + + global __doc__ + __doc__ = ( + __doc__ + "\n" + "\n".join(doc(code) for code in sorted(_codes)) + if __doc__ is not None + else None + ) + + +_init() diff --git a/llmeval-env/lib/python3.10/site-packages/requests/structures.py b/llmeval-env/lib/python3.10/site-packages/requests/structures.py new file mode 100644 index 0000000000000000000000000000000000000000..188e13e4829591facb23ae0e2eda84b9807cb818 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/requests/structures.py @@ -0,0 +1,99 @@ +""" +requests.structures +~~~~~~~~~~~~~~~~~~~ + +Data structures that power Requests. +""" + +from collections import OrderedDict + +from .compat import Mapping, MutableMapping + + +class CaseInsensitiveDict(MutableMapping): + """A case-insensitive ``dict``-like object. + + Implements all methods and operations of + ``MutableMapping`` as well as dict's ``copy``. Also + provides ``lower_items``. + + All keys are expected to be strings. The structure remembers the + case of the last key to be set, and ``iter(instance)``, + ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` + will contain case-sensitive keys. However, querying and contains + testing is case insensitive:: + + cid = CaseInsensitiveDict() + cid['Accept'] = 'application/json' + cid['aCCEPT'] == 'application/json' # True + list(cid) == ['Accept'] # True + + For example, ``headers['content-encoding']`` will return the + value of a ``'Content-Encoding'`` response header, regardless + of how the header name was originally stored. + + If the constructor, ``.update``, or equality comparison + operations are given keys that have equal ``.lower()``s, the + behavior is undefined. + """ + + def __init__(self, data=None, **kwargs): + self._store = OrderedDict() + if data is None: + data = {} + self.update(data, **kwargs) + + def __setitem__(self, key, value): + # Use the lowercased key for lookups, but store the actual + # key alongside the value. + self._store[key.lower()] = (key, value) + + def __getitem__(self, key): + return self._store[key.lower()][1] + + def __delitem__(self, key): + del self._store[key.lower()] + + def __iter__(self): + return (casedkey for casedkey, mappedvalue in self._store.values()) + + def __len__(self): + return len(self._store) + + def lower_items(self): + """Like iteritems(), but with all lowercase keys.""" + return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items()) + + def __eq__(self, other): + if isinstance(other, Mapping): + other = CaseInsensitiveDict(other) + else: + return NotImplemented + # Compare insensitively + return dict(self.lower_items()) == dict(other.lower_items()) + + # Copy is required + def copy(self): + return CaseInsensitiveDict(self._store.values()) + + def __repr__(self): + return str(dict(self.items())) + + +class LookupDict(dict): + """Dictionary lookup object.""" + + def __init__(self, name=None): + self.name = name + super().__init__() + + def __repr__(self): + return f"" + + def __getitem__(self, key): + # We allow fall-through here, so values default to None + + return self.__dict__.get(key, None) + + def get(self, key, default=None): + return self.__dict__.get(key, default) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/checker/_common.py b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_common.py new file mode 100644 index 0000000000000000000000000000000000000000..ed4ef4e44384bab1c22c483dbe75cde24967f5a5 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_common.py @@ -0,0 +1,28 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +import decimal +import math + + +def isstring(value): + return isinstance(value, (str,) + (str, bytes)) + + +def isinf(value): + try: + return decimal.Decimal(value).is_infinite() + except OverflowError: + return True + except TypeError: + return False + except (ValueError, decimal.InvalidOperation): + return False + + +def isnan(value): + try: + return math.isnan(value) + except (TypeError, OverflowError): + return False diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/checker/_dictionary.py b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_dictionary.py new file mode 100644 index 0000000000000000000000000000000000000000..1f1106a78326b638b17c0748de1128ec51b6f90f --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_dictionary.py @@ -0,0 +1,28 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from ._checker import CheckerFactory, TypeCheckerBase, TypeCheckerDelegator + + +class DictionaryTypeCheckerStrictLevel0(TypeCheckerBase): + def is_instance(self): + return isinstance(self._value, dict) + + def is_valid_after_convert(self, converted_value): + return isinstance(converted_value, dict) and converted_value + + +class DictionaryTypeCheckerStrictLevel1(DictionaryTypeCheckerStrictLevel0): + def is_exclude_instance(self): + return not isinstance(self._value, dict) + + +_factory = CheckerFactory( + checker_mapping={0: DictionaryTypeCheckerStrictLevel0, 1: DictionaryTypeCheckerStrictLevel1} +) + + +class DictionaryTypeChecker(TypeCheckerDelegator): + def __init__(self, value, strict_level): + super().__init__(value=value, checker_factory=_factory, strict_level=strict_level) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/checker/_infinity.py b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_infinity.py new file mode 100644 index 0000000000000000000000000000000000000000..cf263081769d98df2b87e34f72eee45575247572 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_infinity.py @@ -0,0 +1,32 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from ._checker import CheckerFactory, TypeCheckerBase, TypeCheckerDelegator +from ._common import isinf, isstring + + +class InfinityCheckerStrictLevel0(TypeCheckerBase): + def is_instance(self): + return isinf(self._value) + + def is_valid_after_convert(self, converted_value): + try: + return converted_value.is_infinite() + except AttributeError: + return False + + +class InfinityCheckerStrictLevel1(InfinityCheckerStrictLevel0): + def is_exclude_instance(self): + return isstring(self._value) + + +_factory = CheckerFactory( + checker_mapping={0: InfinityCheckerStrictLevel0, 1: InfinityCheckerStrictLevel1} +) + + +class InfinityTypeChecker(TypeCheckerDelegator): + def __init__(self, value, strict_level): + super().__init__(value=value, checker_factory=_factory, strict_level=strict_level) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/checker/_interface.py b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_interface.py new file mode 100644 index 0000000000000000000000000000000000000000..002c9bbe4a9b04c853af5eeb3d67687ffaa76d23 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_interface.py @@ -0,0 +1,15 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +import abc + + +class TypeCheckerInterface(metaclass=abc.ABCMeta): + @abc.abstractmethod + def is_type(self) -> bool: # pragma: no cover + pass + + @abc.abstractmethod + def validate(self) -> None: # pragma: no cover + pass diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/checker/_ipaddress.py b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_ipaddress.py new file mode 100644 index 0000000000000000000000000000000000000000..697f929a041e09ad596e7b4dd41d7f98fb2deef0 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_ipaddress.py @@ -0,0 +1,35 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from ._checker import CheckerFactory, TypeCheckerBase, TypeCheckerDelegator +from ._common import isstring + + +class IpAddressTypeCheckerStrictLevel0(TypeCheckerBase): + def is_instance(self): + return self._is_ipaddress(self._value) + + def is_valid_after_convert(self, converted_value): + return self._is_ipaddress(converted_value) + + @staticmethod + def _is_ipaddress(value): + import ipaddress + + return isinstance(value, (ipaddress.IPv4Address, ipaddress.IPv6Address)) + + +class IpAddressTypeCheckerStrictLevel1(IpAddressTypeCheckerStrictLevel0): + def is_exclude_instance(self): + return isstring(self._value) or super().is_exclude_instance() + + +_factory = CheckerFactory( + checker_mapping={0: IpAddressTypeCheckerStrictLevel0, 1: IpAddressTypeCheckerStrictLevel1} +) + + +class IpAddressTypeChecker(TypeCheckerDelegator): + def __init__(self, value, strict_level): + super().__init__(value=value, checker_factory=_factory, strict_level=strict_level) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/checker/_list.py b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_list.py new file mode 100644 index 0000000000000000000000000000000000000000..d66d2c0eae9f0ca71ffdf92f398f4ba88fc29010 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/checker/_list.py @@ -0,0 +1,32 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from ._checker import CheckerFactory, TypeCheckerBase, TypeCheckerDelegator +from ._common import isstring + + +class ListTypeCheckerStrictLevel0(TypeCheckerBase): + def is_instance(self): + return isinstance(self._value, list) + + def is_valid_after_convert(self, converted_value): + return isinstance(converted_value, list) and converted_value + + def is_exclude_instance(self): + return isstring(self._value) + + +class ListTypeCheckerStrictLevel1(ListTypeCheckerStrictLevel0): + def is_exclude_instance(self): + return super().is_exclude_instance() or not isinstance(self._value, list) + + +_factory = CheckerFactory( + checker_mapping={0: ListTypeCheckerStrictLevel0, 1: ListTypeCheckerStrictLevel1} +) + + +class ListTypeChecker(TypeCheckerDelegator): + def __init__(self, value, strict_level): + super().__init__(value=value, checker_factory=_factory, strict_level=strict_level) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__init__.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..181ad66b1c20536f332dfbafb9cf12765bef36a5 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/__init__.py @@ -0,0 +1,37 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from ._base import AbstractType +from ._binary import Binary +from ._bool import Bool +from ._bytes import Bytes +from ._datetime import DateTime +from ._dictionary import Dictionary +from ._infinity import Infinity +from ._integer import Integer +from ._ipaddress import IpAddress +from ._list import List +from ._nan import Nan +from ._none import NoneType +from ._realnumber import RealNumber +from ._string import NullString, String + + +__all__ = ( + "AbstractType", + "Binary", + "Bool", + "Bytes", + "DateTime", + "Dictionary", + "Infinity", + "Integer", + "IpAddress", + "List", + "Nan", + "NoneType", + "NullString", + "RealNumber", + "String", +) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d774a2ae460c0a044406b8d96b9fba7b86a8415 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/__init__.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_base.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_base.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8ac5d929e9fa524e6f64d9db7cd7597418a6ad81 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_base.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_binary.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_binary.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0f7e9aeb8a39b3c3cdd36ca917b2f1d518b9216c Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_binary.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_bool.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_bool.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb2222a766ce9a8f03080071fe7f1f2b91176b9f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_bool.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_bytes.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_bytes.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2875120404d620229363c0fc9b75de8ec4ffaad9 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_bytes.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_datetime.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_datetime.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0b745ad8c72e56443fcce53513ece6e31260d13f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_datetime.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_dictionary.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_dictionary.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..47e8b687d3e69d2a88458751014f90e16dbe35a0 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_dictionary.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_infinity.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_infinity.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..99e48fc6edcb41cac0c5c0866ccd2df1f4991c23 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_infinity.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_integer.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_integer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a264d23a26c0c04d7f8191ec3f9332d6edf3a616 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_integer.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_ipaddress.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_ipaddress.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cc95f7087f0e1ea8180707e049c0492e2a99318f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_ipaddress.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_list.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_list.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9776942a7f054cb8ce2c3c4c118a000d2a4bb32a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_list.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_nan.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_nan.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..579c91c5e1450a936efa2d5a2e13f1bf023be85a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_nan.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_none.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_none.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb08ae8dd15be14c7e22db1ca1a581f21cbb8a04 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_none.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_realnumber.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_realnumber.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0f0566c36dd8df3e117ef7d5b363905f314fd2c3 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_realnumber.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_string.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_string.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c4903d2aae788a7af5a183b449c12461428804cb Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/typepy/type/__pycache__/_string.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_base.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_base.py new file mode 100644 index 0000000000000000000000000000000000000000..5220e85f672653833364acc06aba57400f576f92 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_base.py @@ -0,0 +1,138 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +import abc +from typing import Any, Optional + +from .._typecode import Typecode +from ..checker._interface import TypeCheckerInterface +from ..converter import ValueConverterInterface +from ..error import TypeConversionError + + +class AbstractType(TypeCheckerInterface, ValueConverterInterface): + __slots__ = ( + "_data", + "_strict_level", + "_params", + "__checker", + "__converter", + "__is_type_result", + ) + + @abc.abstractproperty + def typecode(self) -> Typecode: # pragma: no cover + pass + + @abc.abstractmethod + def _create_type_checker(self): # pragma: no cover + pass + + @abc.abstractmethod + def _create_type_converter(self): # pragma: no cover + pass + + @property + def typename(self) -> str: + return self.typecode.name + + def __init__(self, value: Any, strict_level: int, **kwargs) -> None: + self._data = value + self._strict_level = strict_level + self._params = kwargs + + self.__checker = self._create_type_checker() + self.__converter = self._create_type_converter() + + self.__is_type_result: Optional[bool] = None + + def __repr__(self) -> str: + return ", ".join( + [ + f"value={self._data}", + f"typename={self.typename}", + f"strict_level={self._strict_level}", + f"is_type={self.is_type()}", + f"try_convert={self.try_convert()}", + ] + ) + + def is_type(self) -> bool: + """ + :return: + :rtype: bool + """ + + if self.__is_type_result is not None: + return self.__is_type_result + + self.__is_type_result = self.__is_type() + + return self.__is_type_result + + def __is_type(self) -> bool: + if self.__checker.is_type(): + return True + + if self.__checker.is_exclude_instance(): + return False + + try: + self._converted_value = self.__converter.force_convert() + except TypeConversionError: + return False + + if not self.__checker.is_valid_after_convert(self._converted_value): + return False + + return True + + def validate(self, error_message: Optional[str] = None) -> None: + """ + :raises TypeError: + If the value is not matched the type that the class represented. + """ + + if self.is_type(): + return + + if not error_message: + error_message = "invalid value type" + + raise TypeError(f"{error_message}: expected={self.typename}, actual={type(self._data)}") + + def convert(self): + """ + :return: Converted value. + :raises typepy.TypeConversionError: + If the value cannot convert. + """ + + if self.is_type(): + return self.force_convert() + + raise TypeConversionError( + "failed to convert {} from {} to {}".format( + self._data, type(self._data).__name__, self.typename + ) + ) + + def force_convert(self): + """ + :return: Converted value. + :raises typepy.TypeConversionError: + If the value cannot convert. + """ + + return self.__converter.force_convert() + + def try_convert(self): + """ + :return: Converted value. |None| if failed to convert. + """ + + try: + return self.convert() + except TypeConversionError: + return None diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_binary.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_binary.py new file mode 100644 index 0000000000000000000000000000000000000000..a60ae6951a060df7ad32cc4629e40e99f664193d --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_binary.py @@ -0,0 +1,34 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ._base import AbstractType + + +class Binary(AbstractType): + """ + |result_matrix_desc| + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.STRING + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + from ..checker import BytesTypeChecker + + return BytesTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + from ..converter import BytesConverter + + return BytesConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_bool.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_bool.py new file mode 100644 index 0000000000000000000000000000000000000000..1641e5008226f3650d2ed2589cff1a3048e132a2 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_bool.py @@ -0,0 +1,37 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ._base import AbstractType + + +class Bool(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_bool_type.txt + + .. py:attribute:: strict_level + + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.BOOL + + def __init__(self, value: Any, strict_level: int = 2, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + from ..checker._bool import BoolTypeChecker + + return BoolTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + from ..converter._bool import BoolConverter + + return BoolConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_bytes.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_bytes.py new file mode 100644 index 0000000000000000000000000000000000000000..2450e5c94d7bc6701cac78a1e7048e5fda837858 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_bytes.py @@ -0,0 +1,34 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ._base import AbstractType + + +class Bytes(AbstractType): + """ + |result_matrix_desc| + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.BYTES + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + from ..checker import BytesTypeChecker + + return BytesTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + from ..converter import BytesConverter + + return BytesConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_infinity.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_infinity.py new file mode 100644 index 0000000000000000000000000000000000000000..687d6fa7ec6e64831f7a19404863f364e8e9bcc6 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_infinity.py @@ -0,0 +1,34 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ..checker import InfinityTypeChecker +from ..converter import FloatConverter +from ._base import AbstractType + + +class Infinity(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_infinity_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.INFINITY + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + return InfinityTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + return FloatConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_ipaddress.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_ipaddress.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b2d20046f4b5f795ae04356e426a62aa9fcc53 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_ipaddress.py @@ -0,0 +1,34 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ..checker import IpAddressTypeChecker +from ..converter import IpAddressConverter +from ._base import AbstractType + + +class IpAddress(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_ipaddress_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.IP_ADDRESS + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + return IpAddressTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + return IpAddressConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_list.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_list.py new file mode 100644 index 0000000000000000000000000000000000000000..62d0d03fce0b6db9bb129a4438e5169d13454514 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_list.py @@ -0,0 +1,34 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ..checker import ListTypeChecker +from ..converter import ListConverter +from ._base import AbstractType + + +class List(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_list_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.LIST + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + return ListTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + return ListConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_nan.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_nan.py new file mode 100644 index 0000000000000000000000000000000000000000..fcf630f1e7a5b805b277ce655e46ca7109068dca --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_nan.py @@ -0,0 +1,34 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ..checker import NanTypeChecker +from ..converter import FloatConverter +from ._base import AbstractType + + +class Nan(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_nan_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.NAN + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + return NanTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + return FloatConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_realnumber.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_realnumber.py new file mode 100644 index 0000000000000000000000000000000000000000..7a9e660c7b63501430f78e572ec22c605d93cc15 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_realnumber.py @@ -0,0 +1,38 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ._base import AbstractType + + +class RealNumber(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_realnumber_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.REAL_NUMBER + + def __init__(self, value: Any, strict_level: int = 0, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + from ..checker._realnumber import RealNumberTypeChecker + + return RealNumberTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + from ..converter._realnumber import FloatConverter + + converter = FloatConverter(self._data, self._params) + + return converter diff --git a/llmeval-env/lib/python3.10/site-packages/typepy/type/_string.py b/llmeval-env/lib/python3.10/site-packages/typepy/type/_string.py new file mode 100644 index 0000000000000000000000000000000000000000..46f273c8384690e0ad323ba1a80ad587d648436f --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/typepy/type/_string.py @@ -0,0 +1,58 @@ +""" +.. codeauthor:: Tsuyoshi Hombashi +""" + +from typing import Any + +from .._typecode import Typecode +from ..checker import NullStringTypeChecker, StringTypeChecker +from ..converter import NullStringConverter, StringConverter +from ._base import AbstractType + + +class String(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_string_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.STRING + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self) -> StringTypeChecker: + return StringTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self) -> StringConverter: + return StringConverter(self._data, self._params) + + +class NullString(AbstractType): + """ + |result_matrix_desc| + + .. include:: matrix_nullstring_type.txt + + :py:attr:`.strict_level` + |strict_level| + """ + + @property + def typecode(self) -> Typecode: + return Typecode.NULL_STRING + + def __init__(self, value: Any, strict_level: int = 1, **kwargs) -> None: + super().__init__(value, strict_level, **kwargs) + + def _create_type_checker(self): + return NullStringTypeChecker(self._data, self._strict_level) + + def _create_type_converter(self): + return NullStringConverter(self._data, self._params) diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/_collections.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/_collections.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d6a78d5f7f3c1792365bea73275b3b6f2637c5e9 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/_collections.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/connection.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/connection.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3ade70485f29e75a47283793214a8c68d88ae046 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/connection.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/filepost.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/filepost.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..992ec7a956a4e723f41403dfb8d23906669aa8f1 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/filepost.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/http2.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/http2.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf12e120072e0dadc5941907590484f65d27aba6 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/http2.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/poolmanager.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/poolmanager.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..00f8d1d63513dad87ac90a8830939a28c7530d1a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/__pycache__/poolmanager.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/response.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/response.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..86666ea6b12d1467ae9e630fcfac50e3f526c3a4 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/response.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/retry.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/retry.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..986cf02fb12f5b0d0ee6a105b82994a4824d6377 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/retry.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/ssl_.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/ssl_.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dea12ef5c6e468628152877a4e851f72cbd031d6 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/ssl_.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/ssl_match_hostname.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/ssl_match_hostname.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9aba2b983d7e27c5401201d06570e9f7003ee5a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/ssl_match_hostname.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/wait.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/wait.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e9c9b7dfacda5ed12da5dda83c08f790ade635ae Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/urllib3/util/__pycache__/wait.cpython-310.pyc differ