
    daf	                         d dl Z d dlZd dlmZmZ eeeeedf   f   Z e j                         fde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y)
    N)DictUnion	FilesSpecspecc                 x    | j                         D ]'  \  }}t        |t        j                  |      |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createpathlibPath)r   prefixnamecontentss       >/root/Python-3.12.4/Lib/test/test_importlib/resources/_path.pybuildr      s5    , **, 6hxf-456    contentc                 B    |j                  d       t        | |       y )NT)exist_ok)r   )mkdirr   r   paths     r   r	   r	   '   s    JJJ	'$r   c                 &    |j                  |        y )N)write_bytesr   s     r   _r   -   s    Wr   c                 *    |j                  | d       y )Nzutf-8)encoding)
write_textr   s     r   r   r   2   s    OOGgO.r   )r
   	functoolstypingr   r   strbytesr   r   r   singledispatchr	   registerr    r   r   <module>r%      s       eC3445	 #/',,. 6	 64  E#ui/0    
 u   /s / /r   