
    daf
                        d dl Z d dlZd dlmZmZ 	 d dlmZmZ ee	ee	e
df   f   Ze G d de             Zdee	ef   defd	Z ej                         fd
edee	ef   fdZe j                   dee	e
ef   fd       Zej$                  de
fd       Zej$                  de	fd       Zej$                  de	fd       Z G d d      Zy# e$ r d dlmZmZ Y w xY w)    N)DictUnion)Protocolruntime_checkable	FilesSpecc                   $    e Zd Zd Zd Zd Zd Zy)	TreeMakerc                      y N )selfargskwargss      4/root/Python-3.12.4/Lib/test/test_importlib/_path.py__truediv__zTreeMaker.__truediv__           c                      y r   r   r   r   s     r   mkdirzTreeMaker.mkdir   r   r   c                      y r   r   r   contentr   s      r   
write_textzTreeMaker.write_text   r   r   c                      y r   r   )r   r   s     r   write_byteszTreeMaker.write_bytes   r   r   N)__name__
__module____qualname__r   r   r   r   r   r   r   r	   r	      s    r   r	   objreturnc                 P    t        | t              r| S t        j                  |       S r   )
isinstancer	   pathlibPath)r    s    r   _ensure_tree_makerr&       s    S),3C',,s2CCr   specprefixc                 d    | j                         D ]  \  }}t        |t        |      |z          y)aX  
    Build a set of files/directories, as described by the spec.

    Each key represents a pathname, and the value represents
    the content. Content may be a nested directory.

    >>> spec = {
    ...     'README.txt': "A README file",
    ...     "foo": {
    ...         "__init__.py": "",
    ...         "bar": {
    ...             "__init__.py": "",
    ...         },
    ...         "baz.py": "# Some code",
    ...     }
    ... }
    >>> target = getfixture('tmp_path')
    >>> build(spec, target)
    >>> target.joinpath('foo/baz.py').read_text(encoding='utf-8')
    '# Some code'
    N)itemscreater&   )r'   r(   namecontentss       r   buildr.   $   s2    2 **, <hx+F3d:;<r   r   c                 B    |j                  d       t        | |       y )NT)exist_ok)r(   )r   r.   r   paths     r   r+   r+   A   s    JJJ	'$r   c                 &    |j                  |        y r   )r   r1   s     r   _r4   G   s    Wr   c                 *    |j                  | d       y Nzutf-8)encodingr   r1   s     r   r4   r4   L       OOGgO.r   c                 *    |j                  | d       y r6   r8   r1   s     r   r4   r4   Q   r9   r   c                   P    e Zd ZdZ ej
                         dfdZd Zd ZeZ	d Z
y)	Recordingz
    A TreeMaker object that records everything that would be written.

    >>> r = Recording()
    >>> build({'foo': {'foo1.txt': 'yes'}, 'bar.txt': 'abc'}, r)
    >>> r.record
    ['foo/foo1.txt', 'bar.txt']
    Nc                 4    || _         ||| _        y g | _        y r   )locrecord)r   r>   r?   s      r   __init__zRecording.__init__`   s     & 2fr   c                 H    t        | j                  |z  | j                        S r   )r<   r>   r?   )r   others     r   r   zRecording.__truediv__d   s    E)4;;77r   c                 `    | j                   j                  t        | j                               y r   )r?   appendstrr>   r   s      r   r   zRecording.write_textg   s    3txx=)r   c                      y r   r   r   s     r   r   zRecording.mkdirl   s    r   )r   r   r   __doc__r$   PurePosixPathr@   r   r   r   r   r   r   r   r<   r<   V   s4     170024 ;8* Kr   r<   )	functoolsr$   typingr   r   r   r   ImportErrortyping_extensionsrE   bytesr   r	   r&   r%   r.   singledispatchr+   registerr4   r<   r   r   r   <module>rP      sF     >2 eC3445	   DE#y.1 Di D %1GLLN<
<#y.!<:  E#ui/0    
 u   /s / / /s / / [  >==>s   C CC