1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
U
Þ=®d;Vã@sPddlmZddlZddlZddlZddlZddlmZddl    m
Z
ddl    m Z ddlm Z ddl mZejr’dd    lmZdd
lmZdd lmZe d ¡Zejd ejdejfdZdddœdd„ZGdd„dƒZGdd„dejeƒZGdd„dƒZGdd„dƒZGdd„deƒZd d dœd d!„Z d d d"œd#d$„Z!Gd%d&„d&ejeƒZ"dS)'é)Ú annotationsN)Ú
ContextVar©Úpartial)Úupdate_wrapper)Ú
attrgetteré)ÚClosingIterator)Ú StartResponse)ÚWSGIApplication)ÚWSGIEnvironmentÚTÚF.)ÚboundzLocal | LocalStackÚNone)ÚlocalÚreturncCs | ¡dS)zûRelease the data for the current context in a :class:`Local` or
    :class:`LocalStack` without using a :class:`LocalManager`.
 
    This should not be needed for modern use cases, and may be removed
    in the future.
 
    .. versionadded:: 0.6.1
    N)Ú__release_local__)r©rúEd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/local.pyÚ release_locals    rc@sŒeZdZdZdZddddœdd„Zd    d
œd d „Zdd œddddœdd„Zdd
œdd„Zdddœdd„Z    ddddœdd„Z
dddœdd„Z dS) ÚLocalaqCreate a namespace of context-local data. This wraps a
    :class:`ContextVar` containing a :class:`dict` value.
 
    This may incur a performance penalty compared to using individual
    context vars, as it has to copy data to avoid mutating the dict
    between nested contexts.
 
    :param context_var: The :class:`~contextvars.ContextVar` to use as
        storage for this local. If not given, one will be created.
        Context vars not created at the global scope may interfere with
        garbage collection.
 
    .. versionchanged:: 2.0
        Uses ``ContextVar`` instead of a custom storage implementation.
    )Z    __storageNz#ContextVar[dict[str, t.Any]] | Noner©Ú context_varrcCs.|dkrtdt|ƒ›dƒ}t |d|¡dS)Nzwerkzeug.Local<ú    >.storageÚ_Local__storage)rÚidÚobjectÚ __setattr__©ÚselfrrrrÚ__init__6szLocal.__init__zt.Iterator[tuple[str, t.Any]]©rcCst|j i¡ ¡ƒS©N)ÚiterrÚgetÚitems©r rrrÚ__iter__@szLocal.__iter__©Úunbound_messageÚstrú
str | NoneÚ
LocalProxy©Únamer*rcCst|||dS)zþCreate a :class:`LocalProxy` that access an attribute on this
        local namespace.
 
        :param name: Proxy this attribute.
        :param unbound_message: The error message that the proxy will
            show if the attribute isn't set.
        r)©r-©r r/r*rrrÚ__call__CszLocal.__call__cCs|j i¡dSr#)rÚsetr'rrrrMszLocal.__release_local__út.Any)r/rcCs(|j i¡}||kr||St|ƒ‚dSr#)rr%ÚAttributeError©r r/ÚvaluesrrrÚ __getattr__Ps zLocal.__getattr__)r/ÚvaluercCs(|j i¡ ¡}|||<|j |¡dSr#)rr%Úcopyr3)r r/r9r7rrrrXszLocal.__setattr__cCs<|j i¡}||kr0| ¡}||=|j |¡nt|ƒ‚dSr#)rr%r:r3r5r6rrrÚ __delattr__]s  zLocal.__delattr__)N) Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__r!r(r2rr8rr;rrrrr#s
 
rc@s~eZdZdZdZddddœdd„Zdd    œd
d „Zd d dœdd„Zdd    œdd„Ze    dd    œdd„ƒZ
dddœddddœdd„Z dS)Ú
LocalStackaŠCreate a stack of context-local data. This wraps a
    :class:`ContextVar` containing a :class:`list` value.
 
    This may incur a performance penalty compared to using individual
    context vars, as it has to copy data to avoid mutating the list
    between nested contexts.
 
    :param context_var: The :class:`~contextvars.ContextVar` to use as
        storage for this local. If not given, one will be created.
        Context vars not created at the global scope may interfere with
        garbage collection.
 
    .. versionchanged:: 2.0
        Uses ``ContextVar`` instead of a custom storage implementation.
 
    .. versionadded:: 0.6.1
    )Ú_storageNzContextVar[list[T]] | NonerrcCs&|dkrtdt|ƒ›dƒ}||_dS)Nzwerkzeug.LocalStack<r)rrrBrrrrr!}szLocalStack.__init__r"cCs|j g¡dSr#)rBr3r'rrrr‡szLocalStack.__release_local__r zlist[T])ÚobjrcCs*|j g¡ ¡}| |¡|j |¡|S)z'Add a new item to the top of the stack.)rBr%r:Úappendr3)r rCÚstackrrrÚpushŠs
 zLocalStack.pushzT | NonecCs<|j g¡}t|ƒdkrdS|d}|j |dd…¡|S)zjRemove the top item from the stack and return it. If the
        stack is empty, return ``None``.
        rNéÿÿÿÿ)rBr%Úlenr3)r rEÚrvrrrÚpop‘s   zLocalStack.popcCs$|j g¡}t|ƒdkrdS|dS)z[The topmost item on the stack.  If the stack is empty,
        `None` is returned.
        rNrG)rBr%rH)r rErrrÚtopžs  zLocalStack.topr)r,r-r.cCst|||dS)a@Create a :class:`LocalProxy` that accesses the top of this
        local stack.
 
        :param name: If given, the proxy access this attribute of the
            top item, rather than the item itself.
        :param unbound_message: The error message that the proxy will
            show if the stack is empty.
        r)r0r1rrrr2ªs zLocalStack.__call__)N)N) r<r=r>r?r@r!rrFrJÚpropertyrKr2rrrrrAhs
  ÿÿrAc@sbeZdZdZdZddddœdd„Zdd    œd
d „Zd d d œdd„Zd d dœdd„Zdd    œdd„Z    dS)Ú LocalManageraManage releasing the data for the current context in one or more
    :class:`Local` and :class:`LocalStack` objects.
 
    This should not be needed for modern use cases, and may be removed
    in the future.
 
    :param locals: A local or list of locals to manage.
 
    .. versionchanged:: 2.1
        The ``ident_func`` was removed.
 
    .. versionchanged:: 0.7
        The ``ident_func`` parameter was added.
 
    .. versionchanged:: 0.6.1
        The :func:`release_local` function can be used instead of a
        manager.
    )ÚlocalsNz<None | (Local | LocalStack | t.Iterable[Local | LocalStack])r)rNrcCs2|dkrg|_nt|tƒr$|g|_n
t|ƒ|_dSr#)rNÚ
isinstancerÚlist)r rNrrrr!Îs
 
 
zLocalManager.__init__r"cCs|jD] }t|ƒqdS)z†Release the data in the locals for this context. Call this at
        the end of each request or use :meth:`make_middleware`.
        N)rNr)r rrrrÚcleanupÙs
zLocalManager.cleanupr )Úapprcsddddœ‡‡fdd„ }|S)z…Wrap a WSGI application so that local data is released
        automatically after the response has been sent for a request.
        r r
zt.Iterable[bytes])ÚenvironÚstart_responsercstˆ||ƒˆjƒSr#)r    rQ)rSrT©rRr rrÚ applicationåsz1LocalManager.make_middleware.<locals>.applicationr)r rRrVrrUrÚmake_middlewareàszLocalManager.make_middleware)ÚfuncrcCst| |¡|ƒS)zòLike :meth:`make_middleware` but used as a decorator on the
        WSGI application function.
 
        .. code-block:: python
 
            @manager.middleware
            def application(environ, start_response):
                ...
        )rrW)r rXrrrÚ
middlewareìs
zLocalManager.middlewarer+cCsdt|ƒj›dt|jƒ›dS)Nú<z  storages: ú>)Útyper<rHrNr'rrrÚ__repr__øszLocalManager.__repr__)N)
r<r=r>r?r@r!rQrWrYr]rrrrrM¸sþ   rMc@steZdZdZdZddddddd    œd
d „Zd d ddœdd„Zdd dddœdd„Zd dœdd„Zd ddddœdd„Z    dS)Ú _ProxyLookupa”Descriptor that handles proxied attribute lookup for
    :class:`LocalProxy`.
 
    :param f: The built-in function this attribute is accessed through.
        Instead of looking up the special method, the function call
        is redone on the object.
    :param fallback: Return this function if the proxy is unbound
        instead of raising a :exc:`RuntimeError`.
    :param is_attr: This proxied name is an attribute, not a function.
        Call the fallback immediately to get the value.
    :param class_value: Value to return when accessed from the
        ``LocalProxy`` class directly. Used for ``__doc__`` so building
        docs still works.
    )Úbind_fÚfallbackÚis_attrÚ class_valuer/NFút.Callable | Nonez t.Any | NoneÚboolr)Úfr`rbrarcsbtˆdƒr"ddddœ‡fdd„ }n$ˆdk    rBddddœ‡fdd„ }nd}||_||_||_||_dS)    NÚ__get__r-r4ú
t.Callable©ÚinstancerCrcsˆ |t|ƒ¡Sr#©rfr\©rirC©rerrr_sz%_ProxyLookup.__init__.<locals>.bind_fcs
tˆ|ƒSr#rrkrlrrr_ s)Úhasattrr_r`rbra)r rer`rbrar_rrlrr!s    
z_ProxyLookup.__init__r-r+)Úownerr/rcCs
||_dSr#©r/)r rnr/rrrÚ __set_name__,sz_ProxyLookup.__set_name__z type | Noner4)rirnrcCsŽ|dkr|jdk    r|jS|Sz | ¡}WnBtk
rj|jdkrD‚|j ||¡}|jrb|ƒYS|YSX|jdk    r‚| ||¡St||jƒSr#)    rbÚ_get_current_objectÚ RuntimeErrorr`rfrar_Úgetattrr/)r rirnrCr`rrrrf/s 
 
 
 
 
 z_ProxyLookup.__get__r"cCs d|j›S)Nzproxy ror'rrrr]Jsz_ProxyLookup.__repr__)riÚargsÚkwargsrcOs| |t|ƒ¡||ŽS)zíSupport calling unbound methods from the class. For example,
        this happens with ``copy.copy``, which does
        ``type(x).__copy__(x)``. ``type(x)`` can't be proxied, so it
        returns the proxy type and descriptor.
        rj)r rirtrurrrr2Msz_ProxyLookup.__call__)NNNF)N)
r<r=r>r?r@r!rprfr]r2rrrrr^üsûr^cs0eZdZdZdZd    ddddœ‡fdd„ Z‡ZS)
Ú    _ProxyIOpz…Look up an augmented assignment method on a proxied object. The
    method is wrapped to return the proxy instead of the object.
    rNrcr)rer`rcs.tƒ ˆ|¡ddddœ‡fdd„ }||_dS)Nr-r4rgrhcs(ddddœ‡‡fdd„ }| |t|ƒ¡S)Nr4r-)r Úotherrcsˆ||ƒˆSr#r©r rw)rerirrÚi_opcs
z0_ProxyIOp.__init__.<locals>.bind_f.<locals>.i_oprj)rirCryrl)rirr_bsz"_ProxyIOp.__init__.<locals>.bind_f)Úsuperr!r_)r rer`r_©Ú    __class__rlrr!]sz_ProxyIOp.__init__)NN)r<r=r>r?r@r!Ú __classcell__rrr{rrvVs
ÿrv)Úoprcs"ddddœ‡fdd„ }t t|¡S)z5Swap the argument order to turn an l-op into an r-op.r4)rCrwrcs
ˆ||ƒSr#r)rCrw©r~rrÚr_oposz_l_to_r_op.<locals>.r_op)ÚtÚcastr)r~r€rrrÚ
_l_to_r_oplsrƒ)ÚorcCs|Sr#r)r„rrrÚ    _identityusr…c@súeZdZUdZdZded<dddœdddd    d
œd d „Zeed d„ddZedd„ddZee    dd„dZ
ee ƒZ ee ƒZeƒZeejƒZeejƒZeejƒZeejƒZeejƒZeejƒZeeƒZeedd„dZ ee!ƒZ"ee#ƒZ$ee%ƒZ&ee'dd„dZ(edd„ddZ)edd„ƒZ*edd„ƒZ+edd„ƒZ,ee-ƒZ.eej/ƒZ0eej1ƒZ2eej3ƒZ4eej5ƒZ6ee7ƒZ8ee9ƒZ:ee;ƒZ<eej=ƒZ>eej?ƒZ@eejAƒZBeejCƒZDeejEƒZFeejGƒZHeejIƒZJeejKƒZLeeMƒZNeeOƒZPeejQƒZReejSƒZTeejUƒZVeejWƒZXeejYƒZZee[ej?ƒƒZ\ee[ejAƒƒZ]ee[ejCƒƒZ^ee[ejEƒƒZ_ee[ejGƒƒZ`ee[ejIƒƒZaee[ejKƒƒZbee[eMƒƒZcee[eOƒƒZdee[ejQƒƒZeee[ejSƒƒZfee[ejUƒƒZgee[ejWƒƒZhee[ejYƒƒZiejejkƒZlejejmƒZnejejoƒZpejejqƒZrejejsƒZtejejuƒZvejejwƒZxejejyƒZzejej{ƒZ|ejej}ƒZ~ejejƒZ€ejejƒZ‚ejejƒƒZ„eej…ƒZ†eej‡ƒZˆee‰ƒZŠeej‹ƒZŒeeƒZŽeeƒZee‘ƒZ’eej“ƒZ”ee•ƒZ–ee—j˜ƒZ™ee—jšƒZ›ee—jœƒZeƒZžeƒZŸeƒZ eƒZ¡eƒZ¢eƒZ£eƒZ¤ee¥j¥ƒZ¦ee¥j§ƒZ¨dS)r-as    A proxy to the object bound to a context-local object. All
    operations on the proxy are forwarded to the bound object. If no
    object is bound, a ``RuntimeError`` is raised.
 
    :param local: The context-local object that provides the proxied
        object.
    :param name: Proxy this attribute from the proxied object.
    :param unbound_message: The error message to show if the
        context-local object is unbound.
 
    Proxy a :class:`~contextvars.ContextVar` to make it easier to
    access. Pass a name to proxy that attribute.
 
    .. code-block:: python
 
        _request_var = ContextVar("request")
        request = LocalProxy(_request_var)
        session = LocalProxy(_request_var, "session")
 
    Proxy an attribute on a :class:`Local` namespace by calling the
    local with the attribute name:
 
    .. code-block:: python
 
        data = Local()
        user = data("user")
 
    Proxy the top item on a :class:`LocalStack` by calling the local.
    Pass a name to proxy that attribute.
 
    .. code-block::
 
        app_stack = LocalStack()
        current_app = app_stack()
        g = app_stack("g")
 
    Pass a function to proxy the return value from that function. This
    was previously used to access attributes of local objects before
    that was supported directly.
 
    .. code-block:: python
 
        session = LocalProxy(lambda: request.session)
 
    ``__repr__`` and ``__class__`` are proxied, so ``repr(x)`` and
    ``isinstance(x, cls)`` will look like the proxied object. Use
    ``issubclass(type(x), LocalProxy)`` to check if an object is a
    proxy.
 
    .. code-block:: python
 
        repr(user)  # <User admin>
        isinstance(user, User)  # True
        issubclass(type(user), LocalProxy)  # True
 
    .. versionchanged:: 2.2.2
        ``__wrapped__`` is set when wrapping an object, not only when
        wrapping a function, to prevent doctest from failing.
 
    .. versionchanged:: 2.2
        Can proxy a ``ContextVar`` or ``LocalStack`` directly.
 
    .. versionchanged:: 2.2
        The ``name`` parameter can be used with any proxied object, not
        only ``Local``.
 
    .. versionchanged:: 2.2
        Added the ``unbound_message`` parameter.
 
    .. versionchanged:: 2.0
        Updated proxied attributes and methods to reflect the current
        data model.
 
    .. versionchanged:: 0.6.1
        The class can be instantiated with a callable.
    )Z    __wrappedrqzt.Callable[[], T]rqNr)z9ContextVar[T] | Local | LocalStack[T] | t.Callable[[], T]r,r)rr/r*rcsê|dkrt‰nt|ƒ‰ˆdkr"d‰tˆtƒrT|dkr<tdƒ‚ddœ‡‡‡fdd„ }nvtˆtƒrvddœ‡‡‡fdd„ }nTtˆtƒr˜ddœ‡‡‡fdd„ }n2tˆƒr¶ddœ‡‡fd    d„ }ntd
tˆƒ›d ƒ‚t     
|d ˆ¡t     
|d |¡dS)Nzobject is not boundz2'name' is required when proxying a 'Local' object.r r"cs.z
ˆˆƒWStk
r(tˆƒd‚YnXdSr#)r5rrr©Úget_namerr*rrrqæs
z0LocalProxy.__init__.<locals>._get_current_objectcsˆj}|dkrtˆƒ‚ˆ|ƒSr#)rKrr©rCr†rrrqîscs4z ˆ ¡}Wntk
r*tˆƒd‚YnXˆ|ƒSr#)r%Ú LookupErrorrrrˆr†rrrqøs
 cs
ˆˆƒƒSr#rr)r‡rrrrqszDon't know how to proxy 'z'.Ú_LocalProxy__wrappedrq) r…rrOrÚ    TypeErrorrArÚcallabler\rr)r rr/r*rqrr†rr!Ós$
 
 
zLocalProxy.__init__cCs
t|ƒjSr#)r\r?r'rrrÚ<lambda> ózLocalProxy.<lambda>T)rbr`racCs|jSr#)rŠr'rrrrrŽ)r`racCsdt|ƒj›dS)NrZz     unbound>)r\r<r'rrrrrŽ)r`cCsdS)NFrr'rrrrrŽcCsgSr#rr'rrrr$rŽcCst|ƒSr#)r\r'rrrr0rŽcCs
t||ƒSr#)rOrxrrrr2rŽcCs
t||ƒSr#)Ú
issubclassrxrrrr3rŽcOs
|||ŽSr#r)r rtrurrrr5rŽ)N)©r<r=r>r?r@Ú__annotations__r!r^Ú __wrapped__Úreprr]r+Ú__str__ÚbytesÚ    __bytes__Ú
__format__ÚoperatorÚltÚ__lt__ÚleÚ__le__ÚeqÚ__eq__ÚneÚ__ne__ÚgtÚ__gt__ÚgeÚ__ge__ÚhashÚ__hash__rdÚ__bool__rsr8ÚsetattrrÚdelattrr;ÚdirÚ__dir__r|Ú__instancecheck__Ú__subclasscheck__r2rHÚ__len__Ú length_hintÚ__length_hint__ÚgetitemÚ __getitem__ÚsetitemÚ __setitem__ÚdelitemÚ __delitem__r$r(ÚnextÚ__next__ÚreversedÚ __reversed__ÚcontainsÚ __contains__ÚaddÚ__add__ÚsubÚ__sub__ÚmulÚ__mul__ÚmatmulÚ
__matmul__ÚtruedivÚ __truediv__ÚfloordivÚ __floordiv__ÚmodÚ__mod__ÚdivmodÚ
__divmod__ÚpowÚ__pow__ÚlshiftÚ
__lshift__ÚrshiftÚ
__rshift__Úand_Ú__and__ÚxorÚ__xor__Úor_Ú__or__rƒÚ__radd__Ú__rsub__Ú__rmul__Ú __rmatmul__Ú __rtruediv__Ú __rfloordiv__Ú__rmod__Ú __rdivmod__Ú__rpow__Ú __rlshift__Ú __rrshift__Ú__rand__Ú__rxor__Ú__ror__rvÚiaddÚ__iadd__ÚisubÚ__isub__ÚimulÚ__imul__ÚimatmulÚ __imatmul__ÚitruedivÚ __itruediv__Ú    ifloordivÚ __ifloordiv__ÚimodÚ__imod__ÚipowÚ__ipow__ÚilshiftÚ __ilshift__ÚirshiftÚ __irshift__ÚiandÚ__iand__ÚixorÚ__ixor__ÚiorÚ__ior__ÚnegÚ__neg__ÚposÚ__pos__ÚabsÚ__abs__ÚinvertÚ
__invert__ÚcomplexÚ __complex__ÚintÚ__int__ÚfloatÚ    __float__ÚindexÚ    __index__ÚroundÚ    __round__ÚmathÚtruncÚ    __trunc__ÚfloorÚ    __floor__ÚceilÚ__ceil__Ú    __enter__Ú__exit__Ú    __await__Ú    __aiter__Ú    __anext__Ú
__aenter__Ú    __aexit__r:Ú__copy__ÚdeepcopyÚ __deepcopy__rrrrr-ysâ
M ýû8ÿÿÿ
 
 
 
 
 
 ÿ   
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
r-)#Ú
__future__rr:rr—ÚtypingrZ contextvarsrÚ    functoolsrrrZwsgir    Ú TYPE_CHECKINGZ_typeshed.wsgir
r r ÚTypeVarr ÚCallableÚAnyrrrÚGenericrArMr^rvrƒr…r-rrrrÚ<module>s0         
 EPDZ