/usr/lib/python3/dist-packages/twisted/python/__pycache__
NameSizeModeActions
compat.cpython-310.pyc153980644editdlrm
components.cpython-310.pyc143640644editdlrm
constants.cpython-310.pyc4680644editdlrm
context.cpython-310.pyc46570644editdlrm
deprecate.cpython-310.pyc252210644editdlrm
failure.cpython-310.pyc189600644editdlrm
fakepwd.cpython-310.pyc72920644editdlrm
filepath.cpython-310.pyc520500644editdlrm
formmethod.cpython-310.pyc127170644editdlrm
htmlizer.cpython-310.pyc35820644editdlrm
lockfile.cpython-310.pyc51380644editdlrm
log.cpython-310.pyc230160644editdlrm
logfile.cpython-310.pyc104590644editdlrm
modules.cpython-310.pyc254690644editdlrm
monkey.cpython-310.pyc23150644editdlrm
procutils.cpython-310.pyc13890644editdlrm
randbytes.cpython-310.pyc37350644editdlrm
rebuild.cpython-310.pyc55780644editdlrm
reflect.cpython-310.pyc191270644editdlrm
release.cpython-310.pyc15250644editdlrm
roots.cpython-310.pyc89330644editdlrm
runtime.cpython-310.pyc56170644editdlrm
sendmsg.cpython-310.pyc25800644editdlrm
shortcut.cpython-310.pyc24640644editdlrm
syslog.cpython-310.pyc33680644editdlrm
systemd.cpython-310.pyc30510644editdlrm
text.cpython-310.pyc42690644editdlrm
threadable.cpython-310.pyc35200644editdlrm
threadpool.cpython-310.pyc105020644editdlrm
url.cpython-310.pyc2790644editdlrm
urlpath.cpython-310.pyc92820644editdlrm
usage.cpython-310.pyc286350644editdlrm
util.cpython-310.pyc279390644editdlrm
versions.cpython-310.pyc3560644editdlrm
win32.cpython-310.pyc48410644editdlrm
zippath.cpython-310.pyc91460644editdlrm
zipstream.cpython-310.pyc88260644editdlrm
_appdirs.cpython-310.pyc8620644editdlrm
_inotify.cpython-310.pyc25800644editdlrm
_pydoctor.cpython-310.pyc57500644editdlrm
_release.cpython-310.pyc181330644editdlrm
_shellcomp.cpython-310.pyc188550644editdlrm
_textattributes.cpython-310.pyc106420644editdlrm
_tzhelper.cpython-310.pyc33850644editdlrm
_url.cpython-310.pyc2690644editdlrm
__init__.cpython-310.pyc5460644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/python/__pycache__/context.cpython-310.pyc (4657B)
o ¯bÖã@s‚UdZddlmZddlmZmZiZeeeeeeffe d<ej Z Gdd„dƒZ Gdd„dƒZ e ƒatjatjad d „Zd S) zÎ Dynamic pseudo-scoping for Python. Call functions with context.call({key: value}, func); func and functions that it calls will be able to use 'context.get(key)' to retrieve 'value'. This is thread-safe. é)Úlocal)ÚDictÚTypeÚdefaultContextDictc@s*eZdZdZdd„Zdd„Zd dd„ZdS) ÚContextTrackeraû A L{ContextTracker} provides a way to pass arbitrary key/value data up and down a call stack without passing them as parameters to the functions on that call stack. This can be useful when functions on the top and bottom of the call stack need to cooperate but the functions in between them do not allow passing the necessary state. For example:: from twisted.python.context import call, get def handleRequest(request): call({'request-id': request.id}, renderRequest, request.url) def renderRequest(url): renderHeader(url) renderBody(url) def renderHeader(url): return "the header" def renderBody(url): return "the body (request id=%r)" % (get("request-id"),) This should be used sparingly, since the lack of a clear connection between the two halves can result in code which is difficult to understand and maintain. @ivar contexts: A C{list} of C{dict}s tracking the context state. Each new L{ContextTracker.callWithContext} pushes a new C{dict} onto this stack for the duration of the call, making the data available to the function called and restoring the previous data once it is complete.. cCs tg|_dS©N)rÚcontexts©Úself©r ú8/usr/lib/python3/dist-packages/twisted/python/context.pyÚ__init__;ó zContextTracker.__init__cOs4|j |¡z ||i|¤ŽW|j ¡S|j ¡w)aK Call C{func(*args, **kw)} such that the contents of C{newContext} will be available for it to retrieve using L{getContext}. @param newContext: A C{dict} of data to push onto the context for the duration of the call to C{func}. @param func: A callable which will be called. @param args: Any additional positional arguments to pass to C{func}. @param kw: Any additional keyword arguments to pass to C{func}. @return: Whatever is returned by C{func} @raise Exception: Whatever is raised by C{func}. )rÚappendÚpop)r Ú newContextÚfuncÚargsÚkwr r r ÚcallWithContext>s zContextTracker.callWithContextNc Cs4t|jƒD]}z||WStyYqw|S)a( Retrieve the value for a key from the context. @param key: The key to look up in the context. @param default: The value to return if C{key} is not found in the context. @return: The value most recently remembered in the context for C{key}. )ÚreversedrÚKeyError)r ÚkeyÚdefaultÚctxr r r Ú getContextVs  ÿzContextTracker.getContextr)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrr r r r rs "rc@s.eZdZdd„Zdd„Zdd„Zd dd „ZdS) ÚThreadedContextTrackercCs tƒ|_dSr)rÚstorager r r r r jrzThreadedContextTracker.__init__cCs0z|jjWStytƒ}|j_|YSwr)r!ÚctÚAttributeErrorr)r r"r r r ÚcurrentContextms   þz%ThreadedContextTracker.currentContextcOs| ¡j||g|¢Ri|¤ŽSr)r$r)r rrrrr r r rtsz&ThreadedContextTracker.callWithContextNcCs| ¡ ||¡Sr)r$r)r rrr r r rwsz!ThreadedContextTracker.getContextr)rrrr r$rrr r r r r is r cCs|atjatjadSr)ÚtheContextTrackerrÚcallrÚget)Úctrr r r ÚinstallContextTracker€s r)N)rÚ threadingrÚtypingrrrÚobjectÚstrÚ__annotations__Ú __setitem__Ú setDefaultrr r%rr&rr'r)r r r r Ús  Q