4V=jddlmZddlmZddlZddlmZddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZejrddlZejd Zejd ZejdZd1dZGddeeeZGddeeefZGddeeefeeefZGddeeefZGddej eefZ!GddeeefZ"Gd d!eeefeeefZ#Gd"d#eeefeeefZ$Gd$d%eeefeeefZ%Gd&d'eeefe"eefZ&Gd(d)eeefeeefZ'Gd*d+ej(e)Z*dd,l m+Z+d2d0Z,dS)3) annotationsNdeepcopy) exceptions)_missing)ImmutableDictMixin)ImmutableListMixin)ImmutableMultiDictMixin)UpdateDictMixinKVTmappingdMultiDict[K, V] | cabc.Mapping[K, V | list[V] | tuple[V, ...] | set[V]] | cabc.Iterable[tuple[K, V]]returncabc.Iterator[tuple[K, V]]c#TKt|tr|dEd{VdSt|tjrP|D]9\}}t|t t tfr |D]}||fV 3||fV:dS|Ed{VdS)zyIterates over the items of a mapping yielding keys and values without dropping any from more complex structures. TmultiN) isinstance MultiDictitemscabcMappinglisttupleset)rkeyvaluevs PC:\PYTHON\_runtimes\venv\Lib\site-packages\werkzeug/datastructures/structures.pyiter_multi_itemsr$s'9%% ==t=,,,,,,,,,,, GT\ * *!--// ! !JC%$s!344 !!!Aq&LLLL!5j     ! !ceZdZdZddZdS) ImmutableListzJAn immutable :class:`list`. .. versionadded:: 0.5 :private: rstrcft|jdt|dSN())type__name__r__repr__selfs r#r/zImmutableList.__repr__5.t**%>> d(;(;>>>>r%Nrr()r. __module__ __qualname____doc__r/r%r#r'r'-s2??????r%r'ceZdZdZejddZejdd Zejdd ZejddZejddZ dddZdS)TypeConversionDictzWorks like a regular dict but the :meth:`get` method can perform type conversions. :class:`MultiDict` and :class:`CombinedMultiDict` are subclasses of this class and provide the same feature. .. versionadded:: 0.5 r rrV | NonecdSNr7r1r s r#getzTypeConversionDict.getA'*sr%defaultrcdSr<r7r1r r@s r#r>zTypeConversionDict.getC,/Cr%rV | TcdSr<r7rBs r#r>zTypeConversionDict.getE03r%r(r-cabc.Callable[[V], T]T | NonecdSr<r7r1r r-s r#r>zTypeConversionDict.getGFIcr%cdSr<r7r1r r@r-s r#r>zTypeConversionDict.getIKN3r%N V | T | Nonecabc.Callable[[V], T] | Nonec ||}n#t$r|cYSwxYw||S ||S#ttf$r|cYSwxYw)aReturn the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found: >>> d = TypeConversionDict(foo='42', bar='blub') >>> d.get('foo', type=int) 42 >>> d.get('bar', -1, type=int) -1 :param key: The key to be looked up. :param default: The default value to be returned if the key can't be looked up. If not further specified `None` is returned. :param type: A callable that is used to cast the value in the :class:`MultiDict`. If a :exc:`ValueError` or a :exc:`TypeError` is raised by this callable the default value is returned. .. versionchanged:: 3.0.2 Returns the default value on :exc:`TypeError`, too. )KeyError ValueError TypeError)r1r r@r-rvs r#r>zTypeConversionDict.getKs}< cBB   NNN  <I 488OI&   NNN s  -AAr rrr:r rr@rrrr rr@rrrDr r(r-rGrrHr r(r@rr-rGrrNNr rr@rOr-rPrrO)r.r4r5r6toverloadr>r7r%r#r9r99sZ***Z*Z///Z/Z333Z3ZIIIZIZNNNZN!%-1 )))))))r%r9c"eZdZdZddZd dZdS) ImmutableTypeConversionDictzpWorks like a :class:`TypeConversionDict` but does not support modifications. .. versionadded:: 0.5 rTypeConversionDict[K, V]c t|SzReturn a shallow mutable copy of this object. Keep in mind that the standard library's :func:`copy` function is a no-op for this class like for any other python immutable type (eg: :class:`tuple`). )r9r0s r#copyz ImmutableTypeConversionDict.copy~s "$'''r%te.Selfc|Sr<r7r0s r#__copy__z$ImmutableTypeConversionDict.__copy__ r%N)rrarrer.r4r5r6rdrgr7r%r#r`r`wsF ((((r%r`ceZdZdZ dXdYfd ZdZd Zd[fd Zd\fd Zd]fd Zd^fd Z d^fd Z e j d_dZ e j d`dZ dXdafd Z dbfd Ze j dcd Ze j ddd"ZdXded$Z dXdffd' Zdgdhfd, Zdifd. Zdjfd/ Zdkfd1 Zdld3ZdXdmd5Ze j dndod:Ze j dpd=Zdqdrd@ZdsdBZdtdFZdudHZe j d]dIZe j dddJZe j dvdMZefdwfdN ZdxfdP Zd_fdQ ZdyfdS ZdldTZ dmdUZ!dzdWZ"xZ#S){ra^A :class:`MultiDict` is a dictionary subclass customized to deal with multiple values for the same key which is for example used by the parsing functions in the wrappers. This is necessary because some HTML form elements pass multiple values for the same key. :class:`MultiDict` implements all standard dictionary methods. Internally, it saves all values for a key as a list, but the standard dict access methods will only return the first value for a key. If you want to gain access to the other values, too, you have to use the `list` methods as explained below. Basic Usage: >>> d = MultiDict([('a', 'b'), ('a', 'c')]) >>> d MultiDict([('a', 'b'), ('a', 'c')]) >>> d['a'] 'b' >>> d.getlist('a') ['b', 'c'] >>> 'a' in d True It behaves like a normal dict thus all dict functions will only return the first value when multiple values for one key are found. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. A :class:`MultiDict` can be constructed from an iterable of ``(key, value)`` tuples, a dict, a :class:`MultiDict` or from Werkzeug 0.2 onwards some keyword parameters. :param mapping: the initial value for the :class:`MultiDict`. Either a regular dict, an iterable of ``(key, value)`` tuples or `None`. .. versionchanged:: 3.1 Implement ``|`` and ``|=`` operators. NrkMultiDict[K, V] | cabc.Mapping[K, V | list[V] | tuple[V, ...] | set[V]] | cabc.Iterable[tuple[K, V]] | NonerNonec|"tdSt|tr?td|DdSt|t jr|i}|D]B\}}t|tttfrt|}|s9n|g}|||<Ct|dSi}|D].\}}| |g |/t|dS)Nc34K|]\}}||ddfVdSr<r7).0kvss r# z%MultiDict.__init__..s2EEEAraAAAZEEEEEEr%) super__init__rrlistsrrrrrr setdefaultappend)r1rtmpr r! __class__s r#ruzMultiDict.__init__sb ? GG         + + " GG  EEW]]__EEE E E E E E  . . "C%mmoo ! ! UedE3%788$ KKE ! !#GE C GG  S ! ! ! ! !C% 6 6 UsB''..u5555 GG  S ! ! ! ! !r%t.AnycDt|Sr<)dictrvr0s r# __getstate__zMultiDict.__getstate__sDJJLL!!!r%r!ctt|dSr<)rtclearupdate)r1r!rzs r# __setstate__zMultiDict.__setstate__s0   ur%cabc.Iterator[K]cDtSr<)rt__iter__r1rzs r#rzMultiDict.__iter__s ww!!!r%r rrc||vr>> d = MultiDict() >>> d.setlist('foo', ['1', '2']) >>> d['foo'] '1' >>> d.getlist('foo') ['1', '2'] :param key: The key for which the values are set. :param new_list: An iterable with the new values for the key. Old values are removed first. N)rtrr)r1r rrzs r#setlistzMultiDict.setlist$s+ Ch00000r%cdSr<r7r=s r#rwzMultiDict.setdefault6rr%r@cdSr<r7rBs r#rwzMultiDict.setdefault8363r%r:c$||vr|||<||S)aGReturns the value for the key if it is in the dict, otherwise it returns `default` and sets that value for `key`. :param key: The key to be looked up. :param default: The default value to be returned if the key is not in the dict. If not further specified it's `None`. r7rBs r#rwzMultiDict.setdefault:s  d??DICyr% default_listcabc.Iterable[V] | Nonec||vr1t|t|pdt|S)aLike `setdefault` but sets multiple values. The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list: >>> d = MultiDict({"foo": 1}) >>> d.setlistdefault("foo").extend([2, 3]) >>> d.getlist("foo") [1, 2, 3] :param key: The key to be looked up. :param default_list: An iterable of default values. It is either copied (in case it was a list) or converted into a list before returned. :return: a :class:`list` r7)rtrrr)r1r rrzs r#setlistdefaultzMultiDict.setlistdefaultGsM& d?? GG  T,*<"%=%= > > >ww""3'''r%Frboolcabc.Iterable[tuple[K, V]]c#KtD]\}}|r |D]}||fV ||dfV dS)aReturn an iterator of ``(key, value)`` pairs. :param multi: If set to `True` the iterator returned will have a pair for each value of each key. Otherwise it will only contain pairs for the first value of each key. rN)rtr)r1rr valuesr!rzs r#rzMultiDict.items_sz!77==?? % %KC %#%%Eu*$$$$%6!9n$$$$  % %r% cabc.Iterable[tuple[K, list[V]]]c#~KtD]\}}|t|fVdS)zuReturn a iterator of ``(key, values)`` pairs, where values is the list of all values associated with the key.N)rtrr)r1r rrzs r#rvzMultiDict.listsosL !77==?? $ $KCtF||# # # # # $ $r%c#fKtD] }|dV dS)zAReturns an iterator of the first value on every key's value list.rNrtr)r1rrzs r#rzMultiDict.valuesws?ggnn&&  F)OOOO  r%cabc.Iterable[list[V]]cDtS)aReturn an iterator of all values associated with a key. Zipping :meth:`keys` and this is the same as calling :meth:`lists`: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> zip(d.keys(), d.listvalues()) == d.lists() True rrs r# listvalueszMultiDict.listvalues~sww~~r%rec,||S)z%Return a shallow copy of this object.rzr0s r#rdzMultiDict.copys~~d###r%memocp|t|d|S)z"Return a deep copy of this object.F)flat)rzrto_dictr1rs r#rzMultiDict.deepcopys,~~ht|||'?'?FFGGGr%.rt.Literal[True] dict[K, V]cdSr<r7r1rs r#rzMultiDict.to_dictsBE#r%t.Literal[False]dict[K, list[V]]cdSr<r7rs r#rzMultiDict.to_dictsCF3r%Tdict[K, V] | dict[K, list[V]]c|r!t|St|S)aReturn the contents as regular dict. If `flat` is `True` the returned dict will only have the first item present, if `flat` is `False` all values will be returned as lists. :param flat: If set to `False` the dict returned will have lists with all the values in it. Otherwise it will only contain the first value for each key. :return: a :class:`dict` )r}rrvrs r#rzMultiDict.to_dicts8  & %% %DJJLL!!!r%rc\t|D]\}}|||dS)aupdate() extends rather than replaces existing key lists: >>> a = MultiDict({'x': 1}) >>> b = MultiDict({'x': 2, 'y': 3}) >>> a.update(b) >>> a MultiDict([('y', 3), ('x', 1), ('x', 2)]) If the value list for a key in ``other_dict`` is empty, no new values will be added to the dict and the key will not be created: >>> x = {'empty_list': []} >>> y = MultiDict() >>> y.update(x) >>> y MultiDict([]) Nr$rr1rr r!s r#rzMultiDict.updates@2+733 ! !JC HHS%  ! !r%other5cabc.Mapping[K, V | list[V] | tuple[V, ...] | set[V]]MultiDict[K, V]ct|tjstS|}|||Sr<)rrrNotImplementedrdr)r1rrUs r#__or__zMultiDict.__or__sB%.. "! ! YY[[ % r%Rcabc.Mapping[K, V | list[V] | tuple[V, ...] | set[V]] | cabc.Iterable[tuple[K, V]]ct|tjtjfstS|||Sr<)rrrIterablerr)r1rs r#__ior__zMultiDict.__ior__s<%$, !>?? "! ! E r%cdSr<r7r=s r#popz MultiDict.pop #r%cdSr<r7rBs r#rz MultiDict.poprCr%rrDcdSr<r7rBs r#rz MultiDict.poprFr%c t|}t|dkrtj||dS#t $r#|t ur|cYStj|dwxYw)aPop the first item for a list on the dict. Afterwards the key is removed from the dict, so additional values are discarded: >>> d = MultiDict({"foo": [1, 2, 3]}) >>> d.pop("foo") 1 >>> "foo" in d False :param key: the key to pop. :param default: if provided the value to return if the key was not in the dictionary. rN)rtrrrrrRr)r1r r@rrzs r#rz MultiDict.pops( ?''++c""C3xx1}} 3C888q6M ? ? ?h&&/44$ >  ?sAAB*B tuple[K, V]c< t}t|ddkrtj|d|d|ddfS#t $r%}tj|jddd}~wwxYw)zPop an item from the dict.r rN)rtpopitemrrrrRargs)r1rerzs r#rzMultiDict.popitems E77??$$D47||q   3DG<<<7DGAJ& & E E E/q :: D EsA(A,, B6 BBcHt|gS)zPop the list for a key from the dict. If the key is not in the dict an empty list is returned. .. versionchanged:: 0.5 If the key does no longer exist a list is returned instead of raising an error. )rtr)r1r rzs r#poplistzMultiDict.poplist sww{{3###r%tuple[K, list[V]]c tS#t$r%}tj|jddd}~wwxYw)z*Pop a ``(key, list)`` tuple from the dict.rN)rtrrRrrr)r1rrzs r# popitemlistzMultiDict.popitemlistsY E77??$$ $ E E E/q :: D Es# A A  Ac*|Sr<)rdr0s r#rgzMultiDict.__copy__syy{{r%c.||S)N)rrrs r# __deepcopy__zMultiDict.__deepcopy__s}}$}'''r%r(cxt|jdt|ddS)Nr+Trr,)r-r.rrr0s r#r/zMultiDict.__repr__!s8t**%IITZZdZ-C-C(D(DIIIIr%r<rrlrrmrr{)r!r{rrmrrr rrrr rr!rrrmr rrrr rr-rGrrr rr-rPrrr rrrrrmr rrrmrW)r rr@r:rr:)r rrrrrFrrrrrrrrrrri)rr{rre).)rrrr)rrrr)T)rrrrrrrrm)rrrr)rrrrerXr rr@rDrrDrrrrr3)$r.r4r5r6rur~rrrrrr]r^rrrwrrrvrrrdrrrrrrrrrrrgrr/ __classcell__rs@r#rrs<))d """"""">"""""""""" 1 1 1 1 1 1******222222Z---Z-ZJJJZJ;?<111111$Z---Z-Z666Z6     ?C(((((((0%%%%%%% $$$$$$      $$$$HHHHHZEEEEZEZFFFZF " " " " "!!!!8    Z###Z#Z///Z/Z333Z3"???????B E E E E E E$$$$$$EEEEEE((((JJJJJJJJr%rc&eZdZdZdZdd Zdd Zd S) _omd_bucketa Wraps values in the :class:`OrderedMultiDict`. This makes it possible to keep an order over multiple different keys. It requires a lot of extra memory and slows down access a lot, but makes it possible to access elements in O(1) and iterate in O(n). )prevr r!nextomd_OrderedMultiDict[K, V]r rr!rrrmc|j|_||_||_d|_|j||_|j ||j_||_dSr<) _last_bucketrr r!r _first_bucket)r1rr r!s r#ruz_omd_bucket.__init__.sT.1.>  .2   $ $C    '$(C  !r%c|jr|j|j_|jr|j|j_|j|ur |j|_|j|ur|j|_dSdSr<)rrrr)r1rs r#unlinkz_omd_bucket.unlink:sj 9 '!YDIN 9 '!YDIN   $ $ $ C   t # ##yC    $ #r%N)rrr rr!rrrm)rrrrm)r.r4r5r6 __slots__rurr7r%r#rr%sM 1I     ))))))r%rceZdZdZ dEdFfd ZdGd ZdZdHdZdIdZdJdZ dKdZ dLdZ dMdZ dNdZ dOdZdPdZdQdRd#ZdSd%ZdTd'ZdLd(ZejdUd*ZejdVd.Z dEdWd1ZdXd3ZdEdYd6ZdZd8ZdUd9ZejdKd:Zejd[d<Zejd\d?Zefd]d@Zd^dBZd_dDZxZS)`_OrderedMultiDictaWorks like a regular :class:`MultiDict` but preserves the order of the fields. To convert the ordered multi dict into a list you can use the :meth:`items` method and pass it ``multi=True``. In general an :class:`OrderedMultiDict` is an order of magnitude slower than a :class:`MultiDict`. .. admonition:: note Due to a limitation in Python you cannot convert an ordered multi dict into a regular dict by using ``dict(multidict)``. Instead you have to use the :meth:`to_dict` method, otherwise the internal bucket objects are exposed. .. deprecated:: 3.1 Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead. Nrrlrrmcddl}|dtdtd|_d|_|||dSdS)Nr^'OrderedMultiDict' is deprecated and will be removed in Werkzeug 3.2. Use 'MultiDict' instead.r stacklevel)warningswarnDeprecationWarningrtrurrr)r1rr rzs r#ruz_OrderedMultiDict.__init__Xs   -     7;6:   KK   r%robjectrcdt|tstSt|trt |d}t |d} |D]&\}}t |\}}||ks||krdS'n#t$rYdSwxYw t |n#t$rYdSwxYwdSt|t|krdS| D]!\}} | || krdS"dS)NTrF) rrrriterrr StopIterationrrvr) r1riter1iter2k1v1k2v2r rs r#__eq__z_OrderedMultiDict.__eq__osh%++ "! ! e. / / $//00E40011E #%%FB!%[[FBRxx288$uu$,%!   uu  U     tt 5 t99E " "5::<<  KC}}S!!V++uu,ts*9&B#!B## B10B15C CCprotocolt.SupportsIndexr{cht|t|dffSNTr)r-rrr1rs r# __reduce_ex__z_OrderedMultiDict.__reduce_ex__s,DzzD$!7!788:::r%cHt|dSr)rrr0s r#r~z_OrderedMultiDict.__getstate__sDJJTJ**+++r%rcj||D]\}}|||dSr<)rr)r1rr r!s r#rz_OrderedMultiDict.__setstate__sC   ! !JC HHS%  ! !r%r rrc~||vr&t||djStj|Nr)r}rr!rrr=s r#rz_OrderedMultiDict.__getitem__s: $;;##D#..q17 7+C000r%r!c\|||||dSr<rrr1r r!s r#rz_OrderedMultiDict.__setitem__s. S er%c0||dSr<)rr=s r# __delitem__z_OrderedMultiDict.__delitem__s  r%cabc.Iterable[K]c>d|DS)Nc3 K|] \}}|V dSr<r7)rpr _s r#rsz)_OrderedMultiDict.keys..s&//Q//////r%rr0s r#keysz_OrderedMultiDict.keyss//$**,,////r%rcDt|Sr<)rr,r0s r#rz_OrderedMultiDict.__iter__sDIIKK   r%rc>d|DS)Nc3 K|] \}}|V dSr<r7)rpr r!s r#rsz+_OrderedMultiDict.values..s&55*#u555555r%r+r0s r#rz_OrderedMultiDict.valuess55 5555r%Frrc#K|j}|r||j|jfV|j}|dSdSt }|>|j|vr*||j|j|jfV|j}|z-_OrderedMultiDict.getlist..s(((AG(((r%)r}rrRrxr!rSrT)r1r r-rUrrs r#rz_OrderedMultiDict.getlists  !!$,,BB   III  <((R((( (  D  dd4:..//// *     s --#A))A=<A=rcf|||D]}|||dSr<r#)r1r rr!s r#rz_OrderedMultiDict.setlistsD S ! !E HHS%  ! !r%r t.NoReturnc td)Nz5setlistdefault is unsupported for ordered multi dicts)rT)r1r rs r#rz _OrderedMultiDict.setlistdefaultsOPPPr%rc\t|D]\}}|||dSr<rrs r#rz_OrderedMultiDict.updates@+733 ! !JC HHS%  ! !r%ct||d}|D]}||d|DS)Nr7cg|] }|j Sr7r<r=s r#r?z-_OrderedMultiDict.poplist..s)))A)))r%)r}rr)r1r bucketsbuckets r#rz_OrderedMultiDict.poplistsO48HHT34K4K  F MM$    ))))))r%cdSr<r7r=s r#rz_OrderedMultiDict.poprr%r@cdSr<r7rBs r#rz_OrderedMultiDict.poprCr%rrDcdSr<r7rBs r#rz_OrderedMultiDict.poprFr%c t||}n0#t$r#|tur|cYSt j|dwxYw|D]}|||djSr!)r}rrRrrrrr!)r1r r@rFrGs r#rz_OrderedMultiDict.pops ?hhtS))GG ? ? ?h&&/44$ >  ?   F MM$    qzsA A rc t|\}}n2#t$r%}tj|jddd}~wwxYw|D]}||||djfSr!)r}rrRrrrrr!r1r rFrrGs r#rz_OrderedMultiDict.popitems E<<--LC E E E/q :: D E  F MM$    GAJ$$$ A A  Arc t|\}}n2#t$r%}tj|jddd}~wwxYw|D]}|||d|DfS)Nrcg|] }|j Sr7r<r=s r#r?z1_OrderedMultiDict.popitemlist..-s...QW...r%)r}rrRrrrrrMs r#rz_OrderedMultiDict.popitemlist!s E<<--LC E E E/q :: D E  F MM$    ..g.....rNr<r)rr rrrrrr{r)rr{rrmrrrrr'rrrrrrrrrr)r r{rr{rrArrWrXrrr) r.r4r5r6rur__hash__rr~rrrr&r,rrrrvrrr]r^rrrrrrrrrrrs@r#rrEs2 !!!!!!!.2H;;;;,,,,!!!! 1111 0000!!!!6666     MMMMZ---Z-ZJJJZJ;?&!!!! QQQQQ ! ! ! !**** Z###Z#Z///Z/Z333Z3"     ( % % % % / / / / / / / /r%rceZdZdZdEdZdFdGfd ZedFdHdZdIdZe j dJdZ e j dKdZ e j dLdZ e j dMdZ e j dNd Z dOdPd#Z e j dQd%Z e j dRd'Z dFdSd)Z dTd+Z dUd-ZdVd/Ze j dWd1Ze j dXd5Z dYdZd9Zd[d;Zd\d<Zd]d>Zd^d@Zd_dBZd`dCZdadDZxZS)bCombinedMultiDicta>A read only :class:`MultiDict` that you can pass multiple :class:`MultiDict` instances as sequence and it will combine the return values of all wrapped dicts: >>> from werkzeug.datastructures import CombinedMultiDict, MultiDict >>> post = MultiDict([('foo', 'bar')]) >>> get = MultiDict([('blub', 'blah')]) >>> combined = CombinedMultiDict([get, post]) >>> combined['foo'] 'bar' >>> combined['blub'] 'blah' This works for all read operations and will raise a `TypeError` for methods that usually change data which isn't possible. From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP exceptions. rrrr{c0t||jffSr<)r-dictsrs r#rzCombinedMultiDict.__reduce_ex__GsDzzDJ=((r%NrW%cabc.Iterable[MultiDict[K, V]] | Nonermcttt|pd|_dS)Nr7)rtrurrW)r1rWrzs r#ruzCombinedMultiDict.__init__Js0 ,0",=,= r%r,r!rAc2td|jd)Nzcannot create z instances by fromkeys)rTr.)clsr,r!s r#fromkeyszCombinedMultiDict.fromkeysNsOOOOPPPr%r rrcZ|jD]}||vr ||cStj|r<)rWrrr1r ds r#rzCombinedMultiDict.__getitem__Rs?  Aaxxv +C000r%r:cdSr<r7r=s r#r>zCombinedMultiDict.getXr?r%r@cdSr<r7rBs r#r>zCombinedMultiDict.getZrCr%rrDcdSr<r7rBs r#r>zCombinedMultiDict.get\rFr%r(r-rGrHcdSr<r7rJs r#r>zCombinedMultiDict.get^rKr%cdSr<r7rMs r#r>zCombinedMultiDict.get`rNr%rOrPc|jD]=}||vr7|+ |||cS#ttf$rY/wxYw||cS>|Sr<)rWrSrT)r1r r@r-r_s r#r>zCombinedMultiDict.getbs   Aaxx#!#tAcF||+++& 2!!! !v s $88rcdSr<r7r=s r#rzCombinedMultiDict.getlistrrr%rcdSr<r7rJs r#rzCombinedMultiDict.getlisttrr%rcpg}|jD]+}||||,|Sr<)rWextendr)r1r r-rUr_s r#rzCombinedMultiDict.getlistvsB , ,A IIaiiT** + + + + r%set[K]c>td|jDS)zThis function exists so __len__ can be implemented more efficiently, saving one list creation from an iterator. c3$K|] }|D]}|V dSr<r7)rpr_rqs r#rsz/CombinedMultiDict._keys_impl..s/44!44Q14444444r%)rrWr0s r# _keys_implzCombinedMultiDict._keys_impl~s#44dj444444r%r'c*|Sr<)rmr0s r#r,zCombinedMultiDict.keyss   r%rcDt|Sr<)rrmr0s r#rzCombinedMultiDict.__iter__sDOO%%&&&r%rcdSr<r7r0s r#rzCombinedMultiDict.itemsrr%rrrcdSr<r7)r1rs r#rzCombinedMultiDict.itemssQTQTr%Fr=cabc.Iterable[tuple[K, V]] | cabc.Iterable[tuple[K, list[V]]]c#Kt}|jD]E}||D]-\}}|r||fV||vr||||fV.FdSr<)rrWrr)r1rfoundr_r r!s r#rzCombinedMultiDict.itemss % %Aggenn % % U%u*$$$$%%IIcNNNu*$$$  % % %r%rc#FK|D] \}}|V dSr<r+)r1r*r!s r#rzCombinedMultiDict.valuess6   HAuKKKK  r%ci}|jD]E}|D].\}}||g|/F|Sr<)rWrvrwrir)r1rUr_r rs r#rvzCombinedMultiDict.listssk! 6 6A wwyy 6 6 V c2&&--f5555 6xxzzr%rc>d|DS)Nc3&K|] }|dV dS)r Nr7r=s r#rsz/CombinedMultiDict.listvalues..s&++!++++++r%r5r0s r#rzCombinedMultiDict.listvaluess++djjll++++r%rc t|S)a0Return a shallow mutable copy of this object. This returns a :class:`MultiDict` representing the data at the time of copying. The copy will no longer reflect changes to the wrapped dicts. .. versionchanged:: 0.15 Return a mutable :class:`MultiDict`. rr0s r#rdzCombinedMultiDict.copysr%intcDt|Sr<)rrmr0s r#__len__zCombinedMultiDict.__len__s4??$$%%%r%c(|jD] }||vrdS dS)NTF)rWr^s r# __contains__zCombinedMultiDict.__contains__s-  Aaxxttur%c@t|jd|jdSr*)r-r.rWr0s r#r/zCombinedMultiDict.__repr__s$t**%77 7777r%rQr<)rWrXrrm)r,r{r!r{rrArrVrWrXrYrZr[r\rrr)rrjrRr)rr)rrrrr)rrrrrrrrrrrr{)r rrrr3)r.r4r5r6rru classmethodr\rr]r^r>rrmr,rrrrvrrdr}rr/rrs@r#rUrU0s,))))>>>>>>>QQQQ[Q1111 Z***Z*Z///Z/Z333Z3ZIIIZIZNNNZN!%-1  Z---Z-ZJJJZJ;?5555 !!!!''''Z666Z6ZTTTZT! % % % % %,,,,    &&&& 88888888r%rUc*eZdZdZd dZd dZd dZd S) ImmutableDictz;An immutable :class:`dict`. .. versionadded:: 0.5 rr(cft|jdt|dSr*)r-r.r}r/r0s r#r/zImmutableDict.__repr__r2r%rc t|Src)r}r0s r#rdzImmutableDict.copys Dzzr%rec|Sr<r7r0s r#rgzImmutableDict.__copy__rhr%Nr3)rrri)r.r4r5r6r/rdrgr7r%r#rrsZ ????r%rc"eZdZdZddZd dZdS) ImmutableMultiDictz@An immutable :class:`MultiDict`. .. versionadded:: 0.5 rrc t|Srcrzr0s r#rdzImmutableMultiDict.copys r%rec|Sr<r7r0s r#rgzImmutableMultiDict.__copy__rhr%Nrrirjr7r%r#rrsF r%rc@eZdZdZ ddfd Zdd Zdd Zdd ZxZS)_ImmutableOrderedMultiDictzAn immutable :class:`OrderedMultiDict`. .. deprecated:: 3.1 Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead. .. versionadded:: 0.6 Nrrlrrmct|1t|D]#\}}t|||"dSdSr<)rtrur$rr)r1rrqr"rzs r#ruz#_ImmutableOrderedMultiDict.__init__si   (11 2 21!%%dAq1111   2 2r%cabc.Iterable[t.Any]cHt|dSr) enumeraterr0s r#_iter_hashitemsz*_ImmutableOrderedMultiDict._iter_hashitemss$//000r%rc t|Src)rr0s r#rdz_ImmutableOrderedMultiDict.copys !&&&r%rec|Sr<r7r0s r#rgz#_ImmutableOrderedMultiDict.__copy__ rhr%r<r)rr)rrri) r.r4r5r6rurrdrgrrs@r#rrs  2 2 2 2 2 2 21111''''r%rc6eZdZdZ d d fd Zdfd ZxZS) CallbackDictzwA dict that calls a function passed every time something is changed. The function is passed the dict instance. Ninitial6cabc.Mapping[K, V] | cabc.Iterable[tuple[K, V]] | None on_update%cabc.Callable[[te.Self], None] | Nonerrmc|!tn!t|||_dSr<)rtrur)r1rrrzs r#ruzCallbackDict.__init__sF ? GG       GG  W % % %"r%r(cvdt|jdtdS)N< >)r-r.rtr/rs r#r/zCallbackDict.__repr__s5>4::&>>)9)9););>>>>r%r[)rrrrrrmr3)r.r4r5r6rur/rrs@r#rrst KO;? # # # # # # #??????????r%rceZdZdZ d+d,d Zd-d Zd.dZd/dZd-dZd0dZ d0dZ d1dZ d2d3dZ d4dZ d5d Zd6d!Zd7d#Zd8d$Zd9d%Zd:d'Zd;d(Zd4d)Zd4d*ZdS)< HeaderSetaSimilar to the :class:`ETags` class this implements a set-like structure. Unlike :class:`ETags` this is case insensitive and used for vary, allow, and content-language headers. If not constructed using the :func:`parse_set_header` function the instantiation works like this: >>> hs = HeaderSet(['foo', 'bar', 'baz']) >>> hs HeaderSet(['foo', 'bar', 'baz']) Nheaderscabc.Iterable[str] | Nonerrrrmclt|pd|_d|jD|_||_dS)Nr7c6h|]}|Sr7)lowerr=s r# z%HeaderSet.__init__..6s 6661QWWYY666r%)r_headers_setr)r1rrs r#ruzHeaderSet.__init__0s9 W]++ 66 666 "r%headerr(c2||fdS)zAdd a new header to the set.N)rr1rs r#rz HeaderSet.add9s VIr%r1recF|}||jvrt||j|t |jD]'\}}||kr |j|=n(|j||dSdS)aCRemove a header from the set. This raises an :exc:`KeyError` if the header is not in the set. .. versionchanged:: 0.5 In older versions a :exc:`IndexError` was raised instead of a :exc:`KeyError` if the object was missing. :param header: the header to be removed. N)rrrRremoverrr)r1rr idxs r#rzHeaderSet.remove=sllnn di  6"" " !$-00  HCyy{{f$$M#&% > % NN4  & %r%iterablecabc.Iterable[str]cd}|D]U}|}||jvr6|j||j|d}V|r|j||dSdSdS)zAdd all the headers from the iterable to the set. :param iterable: updates the set with the items from the iterable. FTN)rrrrxrr)r1r inserted_anyrr s r#rzHeaderSet.updateRs   $ $F,,..C$)## $$V,,, c"""#  !DN6 NN4  ! !66r%cT ||dS#t$rYdSwxYw)zdLike :meth:`remove` but ignores errors. :param header: the header to be discarded. N)rrRrs r#discardzHeaderSet.discardasA   KK         DD s  ''r{c|}t|jD]!\}}||kr|cS"dS)zReturn the index of the header in the set or return -1 if not found. :param header: the header to be looked up. )rrr)r1rrrs r#findzHeaderSet.findksT "4=11  ICzz||v%% &rr%cZ||}|dkrt||S)zReturn the index of the header in the set or raise an :exc:`IndexError`. :param header: the header to be looked up. r)r IndexError)r1rrUs r#indexzHeaderSet.indexvs1 YYv   66V$$ $ r%c|j|j|j||dSdS)zClear the set.N)rrrrr0s r#rzHeaderSet.clearsP   > % NN4  & %r%Fpreserve_casingrset[str]cV|rt|jSt|jS)aReturn the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost. :param preserve_casing: if set to `True` the items in the set returned will have the original case like in the :class:`HeaderSet`, otherwise they will be lowercase. )rrr)r1rs r#as_setzHeaderSet.as_sets*  &t}%% %49~~r%cfdttj|jS)z2Convert the header set into an HTTP header string.z, )joinmaphttpquote_header_valuerr0s r# to_headerzHeaderSet.to_headers#yyT4dmDDEEEr%rrc|j|Sr<)r)r1rs r#rzHeaderSet.__getitem__s}S!!r%c|j|}|j||j||dSdSr<)rrrrrr)r1rrUs r#r&zHeaderSet.__delitem__s] ]  s # # $$$ > % NN4  & %r%r!c |j|}|j|||j|<|j||j||dSdSr<)rrrrrr)r1rr!olds r#rzHeaderSet.__setitem__s|mC  %%%" c ekkmm$$$ > % NN4  & %r%c8||jvSr<)rrrs r#rzHeaderSet.__contains__s||~~**r%c*t|jSr<)rrr0s r#r}zHeaderSet.__len__s49~~r%cabc.Iterator[str]c*t|jSr<)rrr0s r#rzHeaderSet.__iter__sDM"""r%c*t|jSr<)rrr0s r#__bool__zHeaderSet.__bool__sDIr%c*|Sr<)rr0s r#__str__zHeaderSet.__str__s~~r%c@t|jd|jdSr*)r-r.rr0s r#r/zHeaderSet.__repr__s$t**%:: ::::r%r[)rrrrrrm)rr(rrm)r1rerr(rrm)r1rerrrrm)rr(rr{)r1rerrmr)rrrrr3)rrrr()r1rerrrrm)r1rerrr!r(rrm)rr(rrr)rr)rr)r.r4r5r6rurrrrrrrrrrr&rrr}rrrr/r7r%r#rr#s  .2;?#####!!!!* ! ! ! !        !!!!     FFFF""""!!!! !!!!++++####    ;;;;;;r%r)rnamer(r{cddl}|dkr$|dtdtS|dkr$|dtdtSt |)NrOrderedMultiDictrrrImmutableOrderedMultiDictzp'ImmutableOrderedMultiDict' is deprecated and will be removed in Werkzeug 3.2. Use 'ImmutableMultiDict' instead.)r r r rrAttributeError)rr s r# __getattr__rsOOO !!!  -     !  ***  ?     *)   r%)rrrr)rr(rr{)- __future__rcollections.abcabcrtypingr]rdrr _internalrmixinsr r r r TYPE_CHECKINGtyping_extensionsteTypeVarrrrr$rr'r}r9r`rGenericrrrUrrrr MutableSetr(rrrr7r%r#rs"""""" &&&&&&&&&&&&++++++######?#"""" AIcNN AIcNN AIcNN. ? ? ? ? ?&Q ? ? ?;;;;;ad;;;|"4QT":