o
    g                     @   s   d dl Z d dlZd dlmZmZmZmZ G dd deZeeeee	edf f Z
eG dd deZdeeef d	efd
dZe fde
deeef fddZe jdeee	e
f fddZejde	fddZejdefddZejdefddZdS )    N)DictProtocolUnionruntime_checkablec                   @   s   e Zd ZdZdS )Symlinkz6
    A string indicating the target of a symlink.
    N)__name__
__module____qualname____doc__ r   r   V/var/www/visachat/venv/lib/python3.10/site-packages/importlib_resources/tests/_path.pyr   	   s    r   	FilesSpecc                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )	TreeMakerc                 O      d S Nr   )selfargskwargsr   r   r   __truediv__       zTreeMaker.__truediv__c                 K   r   r   r   )r   r   r   r   r   mkdir   r   zTreeMaker.mkdirc                 K   r   r   r   )r   contentr   r   r   r   
write_text   r   zTreeMaker.write_textc                 C   r   r   r   )r   r   r   r   r   write_bytes   r   zTreeMaker.write_bytesc                 C   r   r   r   )r   targetr   r   r   
symlink_to   r   zTreeMaker.symlink_toN)r   r   r	   r   r   r   r   r   r   r   r   r   r      s    r   objreturnc                 C   s   t | tr| S t| S r   )
isinstancer   pathlibPath)r   r   r   r   _ensure_tree_maker   s   r!   specprefixc                 C   s(   |   D ]\}}t|t||  qdS )a  
    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",
    ...         "bar.py": Symlink("baz.py"),
    ...     },
    ...     "bing": Symlink("foo"),
    ... }
    >>> target = getfixture('tmp_path')
    >>> build(spec, target)
    >>> target.joinpath('foo/baz.py').read_text(encoding='utf-8')
    '# Some code'
    >>> target.joinpath('bing/bar.py').read_text(encoding='utf-8')
    '# Some code'
    N)itemscreater!   )r"   r#   namecontentsr   r   r   build#   s   r(   r   c                 C   s   |j dd t| |d d S )NT)exist_ok)r#   )r   r(   r   pathr   r   r   r%   D   s   r%   c                 C      | |  d S r   )r   r*   r   r   r   _J      r-   c                 C   s   |j | dd d S )Nzutf-8)encoding)r   r*   r   r   r   r-   O   s   c                 C   r,   r   )r   r*   r   r   r   r-   T   r.   )	functoolsr   typingr   r   r   r   strr   bytesr   r   r!   r    r(   singledispatchr%   registerr-   r   r   r   r   <module>   s,    

!