zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
Z±d«ã@s°ddlmZmZddlZddlZddlZddlZddlmZm    Z    dd„Z
dd„Z dd    „Z d
d „Z d d „Zdd„ZGdd„de    ƒZGdd„dedZdej_ej`ej e¡dS)é)ÚwrapsÚpartialN)Ú async_wrapsÚFinalcCst|tjƒrt|ƒ}|S©N)Ú
isinstanceÚpathlibÚPath)Úvalue©r úAd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_path.pyÚ rewrap_path s r cst|ƒ‡fdd„ƒ}|S)Ncst|jˆƒ}|||Ž}t|ƒSr)ÚgetattrÚ_wrappedr )ÚselfÚargsÚkwargsÚattrr
©Ú    attr_namer r Úwrappers 
z!_forward_factory.<locals>.wrapper)r)Úclsrrrr rr Ú_forward_factorysrcs&tƒ‰tˆƒˆf‡‡‡fdd„    ƒ}|S)Ncs6|ˆkrˆ|jƒSt|ˆƒr"|j}ˆ|j|ƒ}t|ƒSr)rrr )rÚotherr
©rrÚsentinelr r r s 
 
 z_forward_magic.<locals>.wrapper)Úobjectr)rrrr rr Ú_forward_magicsrcst||jˆƒ‡fdd„ƒ}|S)NcŸsDt|jˆƒ}t|f|ž|މtj ‡fdd„¡IdH}dd„|DƒS)Ncs
tˆƒƒSr)Úlistr ©Úfuncr r Ú<lambda>3óz7iter_wrapper_factory.<locals>.wrapper.<locals>.<lambda>css|]}t|ƒVqdSr)r )Ú.0Úitemr r r Ú    <genexpr>4sz8iter_wrapper_factory.<locals>.wrapper.<locals>.<genexpr>)rrrÚtrioÚ    to_threadÚrun_sync)rrrÚmethÚitems©Ú    meth_namerr r-s z%iter_wrapper_factory.<locals>.wrapper©rÚ_wraps©rr,rr r+r Úiter_wrapper_factory,s r0cst||jˆƒ‡fdd„ƒ}|S)NcŸs6t|jˆƒ}t|f|ž|Ž}tj |¡IdH}t|ƒSr)rrrr&r'r(r )rrrr)r r
r+r r r:s z'thread_wrapper_factory.<locals>.wrapperr-r/r r+r Úthread_wrapper_factory9s r1cs"tt||jˆƒ‡fdd„ƒƒ}|S)NcŸs6t|jˆƒ}t|f|ž|Ž}tj |¡IdH}t|ƒSr)rr.rr&r'r(r )rrrr)r r
r+r r rEs z,classmethod_wrapper_factory.<locals>.wrapper)Ú classmethodrr.r/r r+r Úclassmethod_wrapper_factoryDs r3cs<eZdZ‡fdd„Zdd„Zdd„Zdd„Zd    d
„Z‡ZS) ÚAsyncAutoWrapperTypecsZtƒ |||¡g|_t|ƒ ||¡t|ƒ ||¡t|ƒ ||¡t|ƒ ||¡dSr)ÚsuperÚ__init__Ú_forwardÚtypeÚgenerate_forwardsÚgenerate_wrapsÚgenerate_magicÚ generate_iter)rÚnameÚbasesÚattrs©Ú    __class__r r r6Qs zAsyncAutoWrapperType.__init__cCsz|jj ¡D]h\}}| d¡s ||kr(q t|tƒr@|j |¡q t|tj    ƒrft
|||ƒ}t |||ƒq t |t |ƒƒ‚q dS©NÚ_)Ú    _forwardsÚ__dict__r*Ú
startswithrÚpropertyr7ÚappendÚtypesÚ FunctionTyperÚsetattrÚ    TypeErrorr8©rr?rrrr r r r9Zs
  z&AsyncAutoWrapperType.generate_forwardscCs‚|jj ¡D]p\}}| d¡s ||kr(q t|tƒrJt||ƒ}t|||ƒq t|tj    ƒrnt
||ƒ}t|||ƒq t |t |ƒƒ‚q dSrB) r.rEr*rFrr2r3rKrIrJr1rLr8rMr r r r:hs
 
 
z#AsyncAutoWrapperType.generate_wrapscCs2|jD]&}t|j|ƒ}t||ƒ}t|||ƒqdSr)rrrDrKrMr r r r;ws
 
z#AsyncAutoWrapperType.generate_magiccCs:|jj ¡D](\}}||jkr t||ƒ}t|||ƒq dSr)r.rEr*Ú
_wrap_iterr0rKrMr r r r<~s
 
z"AsyncAutoWrapperType.generate_iter)    Ú__name__Ú
__module__Ú __qualname__r6r9r:r;r<Ú __classcell__r r r@r r4Ps
     r4c
s‚eZdZdZejZejZdddddddd    d
d g
Z    d d dgZ
dd„Z dd„Z ‡fdd„Z dd„Zdd„Zeejjƒdd„ƒZ‡ZS)r    zlA :class:`pathlib.Path` wrapper that executes blocking methods in
    :meth:`trio.to_thread.run_sync`.
 
    Ú__str__Ú    __bytes__Ú __truediv__Ú __rtruediv__Ú__eq__Ú__lt__Ú__le__Ú__gt__Ú__ge__Ú__hash__ÚglobÚrglobÚiterdircGstj|Ž|_dSr)rr    r)rrr r r r6œsz Path.__init__cCs*||jkrt|j|ƒ}t|ƒSt|ƒ‚dSr)r7rrr ÚAttributeError)rr=r
r r r Ú __getattr__Ÿs
 zPath.__getattr__cstƒ ¡|jSr)r5Ú__dir__r7©rr@r r rb¥sz Path.__dir__cCsd tt|ƒƒ¡S)Nz trio.Path({}))ÚformatÚreprÚstrrcr r r Ú__repr__¨sz Path.__repr__cCs t |j¡Sr)ÚosÚfspathrrcr r r Ú
__fspath__«szPath.__fspath__cÏs0t|jjf|ž|Ž}tj |¡IdH}t |¡S)zfOpen the file pointed to by the path, like the :func:`trio.open_file`
        function does.
 
        N)rrÚopenr&r'r(Z    wrap_file)rrrr r
r r r rk®sz    Path.open)rOrPrQÚ__doc__rr    r.ÚPurePathrDrrNr6rarbrgrjrrkrRr r r@r r    †s,ö
 
r    )Ú    metaclassa—
    Like :meth:`pathlib.Path.iterdir`, but async.
 
    This is an async method that returns a synchronous iterator, so you
    use it like::
 
       for subpath in await mypath.iterdir():
           ...
 
    Note that it actually loads the whole directory list into memory
    immediately, during the initial call. (See `issue #501
    <https://github.com/python-trio/trio/issues/501>`__ for discussion.)
 
)Ú    functoolsrrrhrIrr&Z
trio._utilrrr rrr0r1r3r4r    r_rlÚabsoluteÚPathLikeÚregisterr r r r Ú<module>s 
   64