U
    ½mœd	  ã                   @   s–   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  ¡ fedœdd„Z	ej
eeeef dœdd	„ƒZejedœd
d„ƒZejedœdd„ƒZdS )é    N)ÚDictÚUnionÚ	FilesSpec)Úspecc                 C   s*   |   ¡ D ]\}}t|t |¡| ƒ qdS )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Úcontents© r   úX/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/importlib_resources/tests/_path.pyÚbuild   s    r   )Úcontentc                 C   s   |j dd� t| |d� d S )NT)Úexist_ok)r
   )Úmkdirr   ©r   Úpathr   r   r   r   '   s    r   c                 C   s   |  | ¡ d S )N)Úwrite_bytesr   r   r   r   Ú_-   s    r   c                 C   s   |j | dd� d S )Nzutf-8)Úencoding)Ú
write_textr   r   r   r   r   2   s    )r   Ú	functoolsÚtypingr   r   ÚstrÚbytesr   r	   r   Úsingledispatchr   Úregisterr   r   r   r   r   Ú<module>   s   