summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/multidict
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.11/site-packages/multidict')
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__init__.py48
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__init__.pyi152
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__pycache__/__init__.cpython-311.pycbin1155 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__pycache__/_abc.cpython-311.pycbin2759 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__pycache__/_compat.cpython-311.pycbin722 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_base.cpython-311.pycbin6756 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_py.cpython-311.pycbin29045 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/multidict/_abc.py48
-rw-r--r--venv/lib/python3.11/site-packages/multidict/_compat.py14
-rwxr-xr-xvenv/lib/python3.11/site-packages/multidict/_multidict.cpython-311-x86_64-linux-gnu.sobin410592 -> 0 bytes
-rw-r--r--venv/lib/python3.11/site-packages/multidict/_multidict_base.py144
-rw-r--r--venv/lib/python3.11/site-packages/multidict/_multidict_py.py527
-rw-r--r--venv/lib/python3.11/site-packages/multidict/py.typed1
13 files changed, 0 insertions, 934 deletions
diff --git a/venv/lib/python3.11/site-packages/multidict/__init__.py b/venv/lib/python3.11/site-packages/multidict/__init__.py
deleted file mode 100644
index 23142ee..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__init__.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""Multidict implementation.
-
-HTTP Headers and URL query string require specific data structure:
-multidict. It behaves mostly like a dict but it can have
-several values for the same key.
-"""
-
-from ._abc import MultiMapping, MutableMultiMapping
-from ._compat import USE_EXTENSIONS
-
-__all__ = (
- "MultiMapping",
- "MutableMultiMapping",
- "MultiDictProxy",
- "CIMultiDictProxy",
- "MultiDict",
- "CIMultiDict",
- "upstr",
- "istr",
- "getversion",
-)
-
-__version__ = "6.0.5"
-
-
-try:
- if not USE_EXTENSIONS:
- raise ImportError
- from ._multidict import (
- CIMultiDict,
- CIMultiDictProxy,
- MultiDict,
- MultiDictProxy,
- getversion,
- istr,
- )
-except ImportError: # pragma: no cover
- from ._multidict_py import (
- CIMultiDict,
- CIMultiDictProxy,
- MultiDict,
- MultiDictProxy,
- getversion,
- istr,
- )
-
-
-upstr = istr
diff --git a/venv/lib/python3.11/site-packages/multidict/__init__.pyi b/venv/lib/python3.11/site-packages/multidict/__init__.pyi
deleted file mode 100644
index 0940340..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__init__.pyi
+++ /dev/null
@@ -1,152 +0,0 @@
-import abc
-from typing import (
- Generic,
- Iterable,
- Iterator,
- Mapping,
- MutableMapping,
- TypeVar,
- overload,
-)
-
-class istr(str): ...
-
-upstr = istr
-
-_S = str | istr
-
-_T = TypeVar("_T")
-
-_T_co = TypeVar("_T_co", covariant=True)
-
-_D = TypeVar("_D")
-
-class MultiMapping(Mapping[_S, _T_co]):
- @overload
- @abc.abstractmethod
- def getall(self, key: _S) -> list[_T_co]: ...
- @overload
- @abc.abstractmethod
- def getall(self, key: _S, default: _D) -> list[_T_co] | _D: ...
- @overload
- @abc.abstractmethod
- def getone(self, key: _S) -> _T_co: ...
- @overload
- @abc.abstractmethod
- def getone(self, key: _S, default: _D) -> _T_co | _D: ...
-
-_Arg = (
- Mapping[str, _T]
- | Mapping[istr, _T]
- | dict[str, _T]
- | dict[istr, _T]
- | MultiMapping[_T]
- | Iterable[tuple[str, _T]]
- | Iterable[tuple[istr, _T]]
-)
-
-class MutableMultiMapping(MultiMapping[_T], MutableMapping[_S, _T], Generic[_T]):
- @abc.abstractmethod
- def add(self, key: _S, value: _T) -> None: ...
- @abc.abstractmethod
- def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
- @overload
- @abc.abstractmethod
- def popone(self, key: _S) -> _T: ...
- @overload
- @abc.abstractmethod
- def popone(self, key: _S, default: _D) -> _T | _D: ...
- @overload
- @abc.abstractmethod
- def popall(self, key: _S) -> list[_T]: ...
- @overload
- @abc.abstractmethod
- def popall(self, key: _S, default: _D) -> list[_T] | _D: ...
-
-class MultiDict(MutableMultiMapping[_T], Generic[_T]):
- def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
- def copy(self) -> MultiDict[_T]: ...
- def __getitem__(self, k: _S) -> _T: ...
- def __setitem__(self, k: _S, v: _T) -> None: ...
- def __delitem__(self, v: _S) -> None: ...
- def __iter__(self) -> Iterator[_S]: ...
- def __len__(self) -> int: ...
- @overload
- def getall(self, key: _S) -> list[_T]: ...
- @overload
- def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
- @overload
- def getone(self, key: _S) -> _T: ...
- @overload
- def getone(self, key: _S, default: _D) -> _T | _D: ...
- def add(self, key: _S, value: _T) -> None: ...
- def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
- @overload
- def popone(self, key: _S) -> _T: ...
- @overload
- def popone(self, key: _S, default: _D) -> _T | _D: ...
- @overload
- def popall(self, key: _S) -> list[_T]: ...
- @overload
- def popall(self, key: _S, default: _D) -> list[_T] | _D: ...
-
-class CIMultiDict(MutableMultiMapping[_T], Generic[_T]):
- def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
- def copy(self) -> CIMultiDict[_T]: ...
- def __getitem__(self, k: _S) -> _T: ...
- def __setitem__(self, k: _S, v: _T) -> None: ...
- def __delitem__(self, v: _S) -> None: ...
- def __iter__(self) -> Iterator[_S]: ...
- def __len__(self) -> int: ...
- @overload
- def getall(self, key: _S) -> list[_T]: ...
- @overload
- def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
- @overload
- def getone(self, key: _S) -> _T: ...
- @overload
- def getone(self, key: _S, default: _D) -> _T | _D: ...
- def add(self, key: _S, value: _T) -> None: ...
- def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
- @overload
- def popone(self, key: _S) -> _T: ...
- @overload
- def popone(self, key: _S, default: _D) -> _T | _D: ...
- @overload
- def popall(self, key: _S) -> list[_T]: ...
- @overload
- def popall(self, key: _S, default: _D) -> list[_T] | _D: ...
-
-class MultiDictProxy(MultiMapping[_T], Generic[_T]):
- def __init__(self, arg: MultiMapping[_T] | MutableMultiMapping[_T]) -> None: ...
- def copy(self) -> MultiDict[_T]: ...
- def __getitem__(self, k: _S) -> _T: ...
- def __iter__(self) -> Iterator[_S]: ...
- def __len__(self) -> int: ...
- @overload
- def getall(self, key: _S) -> list[_T]: ...
- @overload
- def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
- @overload
- def getone(self, key: _S) -> _T: ...
- @overload
- def getone(self, key: _S, default: _D) -> _T | _D: ...
-
-class CIMultiDictProxy(MultiMapping[_T], Generic[_T]):
- def __init__(self, arg: MultiMapping[_T] | MutableMultiMapping[_T]) -> None: ...
- def __getitem__(self, k: _S) -> _T: ...
- def __iter__(self) -> Iterator[_S]: ...
- def __len__(self) -> int: ...
- @overload
- def getall(self, key: _S) -> list[_T]: ...
- @overload
- def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
- @overload
- def getone(self, key: _S) -> _T: ...
- @overload
- def getone(self, key: _S, default: _D) -> _T | _D: ...
- def copy(self) -> CIMultiDict[_T]: ...
-
-def getversion(
- md: MultiDict[_T] | CIMultiDict[_T] | MultiDictProxy[_T] | CIMultiDictProxy[_T],
-) -> int: ...
diff --git a/venv/lib/python3.11/site-packages/multidict/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/multidict/__pycache__/__init__.cpython-311.pyc
deleted file mode 100644
index a9377f8..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__pycache__/__init__.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/multidict/__pycache__/_abc.cpython-311.pyc b/venv/lib/python3.11/site-packages/multidict/__pycache__/_abc.cpython-311.pyc
deleted file mode 100644
index 06cc9fb..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__pycache__/_abc.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/multidict/__pycache__/_compat.cpython-311.pyc b/venv/lib/python3.11/site-packages/multidict/__pycache__/_compat.cpython-311.pyc
deleted file mode 100644
index ba6a520..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__pycache__/_compat.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_base.cpython-311.pyc b/venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_base.cpython-311.pyc
deleted file mode 100644
index a229353..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_base.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_py.cpython-311.pyc b/venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_py.cpython-311.pyc
deleted file mode 100644
index 7bcd4e6..0000000
--- a/venv/lib/python3.11/site-packages/multidict/__pycache__/_multidict_py.cpython-311.pyc
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/multidict/_abc.py b/venv/lib/python3.11/site-packages/multidict/_abc.py
deleted file mode 100644
index 0603cdd..0000000
--- a/venv/lib/python3.11/site-packages/multidict/_abc.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import abc
-import sys
-import types
-from collections.abc import Mapping, MutableMapping
-
-
-class _TypingMeta(abc.ABCMeta):
- # A fake metaclass to satisfy typing deps in runtime
- # basically MultiMapping[str] and other generic-like type instantiations
- # are emulated.
- # Note: real type hints are provided by __init__.pyi stub file
- if sys.version_info >= (3, 9):
-
- def __getitem__(self, key):
- return types.GenericAlias(self, key)
-
- else:
-
- def __getitem__(self, key):
- return self
-
-
-class MultiMapping(Mapping, metaclass=_TypingMeta):
- @abc.abstractmethod
- def getall(self, key, default=None):
- raise KeyError
-
- @abc.abstractmethod
- def getone(self, key, default=None):
- raise KeyError
-
-
-class MutableMultiMapping(MultiMapping, MutableMapping):
- @abc.abstractmethod
- def add(self, key, value):
- raise NotImplementedError
-
- @abc.abstractmethod
- def extend(self, *args, **kwargs):
- raise NotImplementedError
-
- @abc.abstractmethod
- def popone(self, key, default=None):
- raise KeyError
-
- @abc.abstractmethod
- def popall(self, key, default=None):
- raise KeyError
diff --git a/venv/lib/python3.11/site-packages/multidict/_compat.py b/venv/lib/python3.11/site-packages/multidict/_compat.py
deleted file mode 100644
index d1ff392..0000000
--- a/venv/lib/python3.11/site-packages/multidict/_compat.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import os
-import platform
-
-NO_EXTENSIONS = bool(os.environ.get("MULTIDICT_NO_EXTENSIONS"))
-
-PYPY = platform.python_implementation() == "PyPy"
-
-USE_EXTENSIONS = not NO_EXTENSIONS and not PYPY
-
-if USE_EXTENSIONS:
- try:
- from . import _multidict # noqa
- except ImportError:
- USE_EXTENSIONS = False
diff --git a/venv/lib/python3.11/site-packages/multidict/_multidict.cpython-311-x86_64-linux-gnu.so b/venv/lib/python3.11/site-packages/multidict/_multidict.cpython-311-x86_64-linux-gnu.so
deleted file mode 100755
index 0891f76..0000000
--- a/venv/lib/python3.11/site-packages/multidict/_multidict.cpython-311-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/multidict/_multidict_base.py b/venv/lib/python3.11/site-packages/multidict/_multidict_base.py
deleted file mode 100644
index 3944665..0000000
--- a/venv/lib/python3.11/site-packages/multidict/_multidict_base.py
+++ /dev/null
@@ -1,144 +0,0 @@
-from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
-
-
-def _abc_itemsview_register(view_cls):
- ItemsView.register(view_cls)
-
-
-def _abc_keysview_register(view_cls):
- KeysView.register(view_cls)
-
-
-def _abc_valuesview_register(view_cls):
- ValuesView.register(view_cls)
-
-
-def _viewbaseset_richcmp(view, other, op):
- if op == 0: # <
- if not isinstance(other, Set):
- return NotImplemented
- return len(view) < len(other) and view <= other
- elif op == 1: # <=
- if not isinstance(other, Set):
- return NotImplemented
- if len(view) > len(other):
- return False
- for elem in view:
- if elem not in other:
- return False
- return True
- elif op == 2: # ==
- if not isinstance(other, Set):
- return NotImplemented
- return len(view) == len(other) and view <= other
- elif op == 3: # !=
- return not view == other
- elif op == 4: # >
- if not isinstance(other, Set):
- return NotImplemented
- return len(view) > len(other) and view >= other
- elif op == 5: # >=
- if not isinstance(other, Set):
- return NotImplemented
- if len(view) < len(other):
- return False
- for elem in other:
- if elem not in view:
- return False
- return True
-
-
-def _viewbaseset_and(view, other):
- if not isinstance(other, Iterable):
- return NotImplemented
- if isinstance(view, Set):
- view = set(iter(view))
- if isinstance(other, Set):
- other = set(iter(other))
- if not isinstance(other, Set):
- other = set(iter(other))
- return view & other
-
-
-def _viewbaseset_or(view, other):
- if not isinstance(other, Iterable):
- return NotImplemented
- if isinstance(view, Set):
- view = set(iter(view))
- if isinstance(other, Set):
- other = set(iter(other))
- if not isinstance(other, Set):
- other = set(iter(other))
- return view | other
-
-
-def _viewbaseset_sub(view, other):
- if not isinstance(other, Iterable):
- return NotImplemented
- if isinstance(view, Set):
- view = set(iter(view))
- if isinstance(other, Set):
- other = set(iter(other))
- if not isinstance(other, Set):
- other = set(iter(other))
- return view - other
-
-
-def _viewbaseset_xor(view, other):
- if not isinstance(other, Iterable):
- return NotImplemented
- if isinstance(view, Set):
- view = set(iter(view))
- if isinstance(other, Set):
- other = set(iter(other))
- if not isinstance(other, Set):
- other = set(iter(other))
- return view ^ other
-
-
-def _itemsview_isdisjoint(view, other):
- "Return True if two sets have a null intersection."
- for v in other:
- if v in view:
- return False
- return True
-
-
-def _itemsview_repr(view):
- lst = []
- for k, v in view:
- lst.append("{!r}: {!r}".format(k, v))
- body = ", ".join(lst)
- return "{}({})".format(view.__class__.__name__, body)
-
-
-def _keysview_isdisjoint(view, other):
- "Return True if two sets have a null intersection."
- for k in other:
- if k in view:
- return False
- return True
-
-
-def _keysview_repr(view):
- lst = []
- for k in view:
- lst.append("{!r}".format(k))
- body = ", ".join(lst)
- return "{}({})".format(view.__class__.__name__, body)
-
-
-def _valuesview_repr(view):
- lst = []
- for v in view:
- lst.append("{!r}".format(v))
- body = ", ".join(lst)
- return "{}({})".format(view.__class__.__name__, body)
-
-
-def _mdrepr(md):
- lst = []
- for k, v in md.items():
- lst.append("'{}': {!r}".format(k, v))
- body = ", ".join(lst)
- return "<{}({})>".format(md.__class__.__name__, body)
diff --git a/venv/lib/python3.11/site-packages/multidict/_multidict_py.py b/venv/lib/python3.11/site-packages/multidict/_multidict_py.py
deleted file mode 100644
index 79c45aa..0000000
--- a/venv/lib/python3.11/site-packages/multidict/_multidict_py.py
+++ /dev/null
@@ -1,527 +0,0 @@
-import sys
-import types
-from array import array
-from collections import abc
-
-from ._abc import MultiMapping, MutableMultiMapping
-
-_marker = object()
-
-if sys.version_info >= (3, 9):
- GenericAlias = types.GenericAlias
-else:
-
- def GenericAlias(cls):
- return cls
-
-
-class istr(str):
-
- """Case insensitive str."""
-
- __is_istr__ = True
-
-
-upstr = istr # for relaxing backward compatibility problems
-
-
-def getversion(md):
- if not isinstance(md, _Base):
- raise TypeError("Parameter should be multidict or proxy")
- return md._impl._version
-
-
-_version = array("Q", [0])
-
-
-class _Impl:
- __slots__ = ("_items", "_version")
-
- def __init__(self):
- self._items = []
- self.incr_version()
-
- def incr_version(self):
- global _version
- v = _version
- v[0] += 1
- self._version = v[0]
-
- if sys.implementation.name != "pypy":
-
- def __sizeof__(self):
- return object.__sizeof__(self) + sys.getsizeof(self._items)
-
-
-class _Base:
- def _title(self, key):
- return key
-
- def getall(self, key, default=_marker):
- """Return a list of all values matching the key."""
- identity = self._title(key)
- res = [v for i, k, v in self._impl._items if i == identity]
- if res:
- return res
- if not res and default is not _marker:
- return default
- raise KeyError("Key not found: %r" % key)
-
- def getone(self, key, default=_marker):
- """Get first value matching the key.
-
- Raises KeyError if the key is not found and no default is provided.
- """
- identity = self._title(key)
- for i, k, v in self._impl._items:
- if i == identity:
- return v
- if default is not _marker:
- return default
- raise KeyError("Key not found: %r" % key)
-
- # Mapping interface #
-
- def __getitem__(self, key):
- return self.getone(key)
-
- def get(self, key, default=None):
- """Get first value matching the key.
-
- If the key is not found, returns the default (or None if no default is provided)
- """
- return self.getone(key, default)
-
- def __iter__(self):
- return iter(self.keys())
-
- def __len__(self):
- return len(self._impl._items)
-
- def keys(self):
- """Return a new view of the dictionary's keys."""
- return _KeysView(self._impl)
-
- def items(self):
- """Return a new view of the dictionary's items *(key, value) pairs)."""
- return _ItemsView(self._impl)
-
- def values(self):
- """Return a new view of the dictionary's values."""
- return _ValuesView(self._impl)
-
- def __eq__(self, other):
- if not isinstance(other, abc.Mapping):
- return NotImplemented
- if isinstance(other, _Base):
- lft = self._impl._items
- rht = other._impl._items
- if len(lft) != len(rht):
- return False
- for (i1, k2, v1), (i2, k2, v2) in zip(lft, rht):
- if i1 != i2 or v1 != v2:
- return False
- return True
- if len(self._impl._items) != len(other):
- return False
- for k, v in self.items():
- nv = other.get(k, _marker)
- if v != nv:
- return False
- return True
-
- def __contains__(self, key):
- identity = self._title(key)
- for i, k, v in self._impl._items:
- if i == identity:
- return True
- return False
-
- def __repr__(self):
- body = ", ".join("'{}': {!r}".format(k, v) for k, v in self.items())
- return "<{}({})>".format(self.__class__.__name__, body)
-
- __class_getitem__ = classmethod(GenericAlias)
-
-
-class MultiDictProxy(_Base, MultiMapping):
- """Read-only proxy for MultiDict instance."""
-
- def __init__(self, arg):
- if not isinstance(arg, (MultiDict, MultiDictProxy)):
- raise TypeError(
- "ctor requires MultiDict or MultiDictProxy instance"
- ", not {}".format(type(arg))
- )
-
- self._impl = arg._impl
-
- def __reduce__(self):
- raise TypeError("can't pickle {} objects".format(self.__class__.__name__))
-
- def copy(self):
- """Return a copy of itself."""
- return MultiDict(self.items())
-
-
-class CIMultiDictProxy(MultiDictProxy):
- """Read-only proxy for CIMultiDict instance."""
-
- def __init__(self, arg):
- if not isinstance(arg, (CIMultiDict, CIMultiDictProxy)):
- raise TypeError(
- "ctor requires CIMultiDict or CIMultiDictProxy instance"
- ", not {}".format(type(arg))
- )
-
- self._impl = arg._impl
-
- def _title(self, key):
- return key.title()
-
- def copy(self):
- """Return a copy of itself."""
- return CIMultiDict(self.items())
-
-
-class MultiDict(_Base, MutableMultiMapping):
- """Dictionary with the support for duplicate keys."""
-
- def __init__(self, *args, **kwargs):
- self._impl = _Impl()
-
- self._extend(args, kwargs, self.__class__.__name__, self._extend_items)
-
- if sys.implementation.name != "pypy":
-
- def __sizeof__(self):
- return object.__sizeof__(self) + sys.getsizeof(self._impl)
-
- def __reduce__(self):
- return (self.__class__, (list(self.items()),))
-
- def _title(self, key):
- return key
-
- def _key(self, key):
- if isinstance(key, str):
- return key
- else:
- raise TypeError(
- "MultiDict keys should be either str " "or subclasses of str"
- )
-
- def add(self, key, value):
- identity = self._title(key)
- self._impl._items.append((identity, self._key(key), value))
- self._impl.incr_version()
-
- def copy(self):
- """Return a copy of itself."""
- cls = self.__class__
- return cls(self.items())
-
- __copy__ = copy
-
- def extend(self, *args, **kwargs):
- """Extend current MultiDict with more values.
-
- This method must be used instead of update.
- """
- self._extend(args, kwargs, "extend", self._extend_items)
-
- def _extend(self, args, kwargs, name, method):
- if len(args) > 1:
- raise TypeError(
- "{} takes at most 1 positional argument"
- " ({} given)".format(name, len(args))
- )
- if args:
- arg = args[0]
- if isinstance(args[0], (MultiDict, MultiDictProxy)) and not kwargs:
- items = arg._impl._items
- else:
- if hasattr(arg, "items"):
- arg = arg.items()
- if kwargs:
- arg = list(arg)
- arg.extend(list(kwargs.items()))
- items = []
- for item in arg:
- if not len(item) == 2:
- raise TypeError(
- "{} takes either dict or list of (key, value) "
- "tuples".format(name)
- )
- items.append((self._title(item[0]), self._key(item[0]), item[1]))
-
- method(items)
- else:
- method(
- [
- (self._title(key), self._key(key), value)
- for key, value in kwargs.items()
- ]
- )
-
- def _extend_items(self, items):
- for identity, key, value in items:
- self.add(key, value)
-
- def clear(self):
- """Remove all items from MultiDict."""
- self._impl._items.clear()
- self._impl.incr_version()
-
- # Mapping interface #
-
- def __setitem__(self, key, value):
- self._replace(key, value)
-
- def __delitem__(self, key):
- identity = self._title(key)
- items = self._impl._items
- found = False
- for i in range(len(items) - 1, -1, -1):
- if items[i][0] == identity:
- del items[i]
- found = True
- if not found:
- raise KeyError(key)
- else:
- self._impl.incr_version()
-
- def setdefault(self, key, default=None):
- """Return value for key, set value to default if key is not present."""
- identity = self._title(key)
- for i, k, v in self._impl._items:
- if i == identity:
- return v
- self.add(key, default)
- return default
-
- def popone(self, key, default=_marker):
- """Remove specified key and return the corresponding value.
-
- If key is not found, d is returned if given, otherwise
- KeyError is raised.
-
- """
- identity = self._title(key)
- for i in range(len(self._impl._items)):
- if self._impl._items[i][0] == identity:
- value = self._impl._items[i][2]
- del self._impl._items[i]
- self._impl.incr_version()
- return value
- if default is _marker:
- raise KeyError(key)
- else:
- return default
-
- pop = popone # type: ignore
-
- def popall(self, key, default=_marker):
- """Remove all occurrences of key and return the list of corresponding
- values.
-
- If key is not found, default is returned if given, otherwise
- KeyError is raised.
-
- """
- found = False
- identity = self._title(key)
- ret = []
- for i in range(len(self._impl._items) - 1, -1, -1):
- item = self._impl._items[i]
- if item[0] == identity:
- ret.append(item[2])
- del self._impl._items[i]
- self._impl.incr_version()
- found = True
- if not found:
- if default is _marker:
- raise KeyError(key)
- else:
- return default
- else:
- ret.reverse()
- return ret
-
- def popitem(self):
- """Remove and return an arbitrary (key, value) pair."""
- if self._impl._items:
- i = self._impl._items.pop(0)
- self._impl.incr_version()
- return i[1], i[2]
- else:
- raise KeyError("empty multidict")
-
- def update(self, *args, **kwargs):
- """Update the dictionary from *other*, overwriting existing keys."""
- self._extend(args, kwargs, "update", self._update_items)
-
- def _update_items(self, items):
- if not items:
- return
- used_keys = {}
- for identity, key, value in items:
- start = used_keys.get(identity, 0)
- for i in range(start, len(self._impl._items)):
- item = self._impl._items[i]
- if item[0] == identity:
- used_keys[identity] = i + 1
- self._impl._items[i] = (identity, key, value)
- break
- else:
- self._impl._items.append((identity, key, value))
- used_keys[identity] = len(self._impl._items)
-
- # drop tails
- i = 0
- while i < len(self._impl._items):
- item = self._impl._items[i]
- identity = item[0]
- pos = used_keys.get(identity)
- if pos is None:
- i += 1
- continue
- if i >= pos:
- del self._impl._items[i]
- else:
- i += 1
-
- self._impl.incr_version()
-
- def _replace(self, key, value):
- key = self._key(key)
- identity = self._title(key)
- items = self._impl._items
-
- for i in range(len(items)):
- item = items[i]
- if item[0] == identity:
- items[i] = (identity, key, value)
- # i points to last found item
- rgt = i
- self._impl.incr_version()
- break
- else:
- self._impl._items.append((identity, key, value))
- self._impl.incr_version()
- return
-
- # remove all tail items
- i = rgt + 1
- while i < len(items):
- item = items[i]
- if item[0] == identity:
- del items[i]
- else:
- i += 1
-
-
-class CIMultiDict(MultiDict):
- """Dictionary with the support for duplicate case-insensitive keys."""
-
- def _title(self, key):
- return key.title()
-
-
-class _Iter:
- __slots__ = ("_size", "_iter")
-
- def __init__(self, size, iterator):
- self._size = size
- self._iter = iterator
-
- def __iter__(self):
- return self
-
- def __next__(self):
- return next(self._iter)
-
- def __length_hint__(self):
- return self._size
-
-
-class _ViewBase:
- def __init__(self, impl):
- self._impl = impl
-
- def __len__(self):
- return len(self._impl._items)
-
-
-class _ItemsView(_ViewBase, abc.ItemsView):
- def __contains__(self, item):
- assert isinstance(item, tuple) or isinstance(item, list)
- assert len(item) == 2
- for i, k, v in self._impl._items:
- if item[0] == k and item[1] == v:
- return True
- return False
-
- def __iter__(self):
- return _Iter(len(self), self._iter(self._impl._version))
-
- def _iter(self, version):
- for i, k, v in self._impl._items:
- if version != self._impl._version:
- raise RuntimeError("Dictionary changed during iteration")
- yield k, v
-
- def __repr__(self):
- lst = []
- for item in self._impl._items:
- lst.append("{!r}: {!r}".format(item[1], item[2]))
- body = ", ".join(lst)
- return "{}({})".format(self.__class__.__name__, body)
-
-
-class _ValuesView(_ViewBase, abc.ValuesView):
- def __contains__(self, value):
- for item in self._impl._items:
- if item[2] == value:
- return True
- return False
-
- def __iter__(self):
- return _Iter(len(self), self._iter(self._impl._version))
-
- def _iter(self, version):
- for item in self._impl._items:
- if version != self._impl._version:
- raise RuntimeError("Dictionary changed during iteration")
- yield item[2]
-
- def __repr__(self):
- lst = []
- for item in self._impl._items:
- lst.append("{!r}".format(item[2]))
- body = ", ".join(lst)
- return "{}({})".format(self.__class__.__name__, body)
-
-
-class _KeysView(_ViewBase, abc.KeysView):
- def __contains__(self, key):
- for item in self._impl._items:
- if item[1] == key:
- return True
- return False
-
- def __iter__(self):
- return _Iter(len(self), self._iter(self._impl._version))
-
- def _iter(self, version):
- for item in self._impl._items:
- if version != self._impl._version:
- raise RuntimeError("Dictionary changed during iteration")
- yield item[1]
-
- def __repr__(self):
- lst = []
- for item in self._impl._items:
- lst.append("{!r}".format(item[1]))
- body = ", ".join(lst)
- return "{}({})".format(self.__class__.__name__, body)
diff --git a/venv/lib/python3.11/site-packages/multidict/py.typed b/venv/lib/python3.11/site-packages/multidict/py.typed
deleted file mode 100644
index dfe8cc0..0000000
--- a/venv/lib/python3.11/site-packages/multidict/py.typed
+++ /dev/null
@@ -1 +0,0 @@
-PEP-561 marker. \ No newline at end of file