
    Fe                        d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
 d dlmZ erd dlZ ej                  ded        ej                         xs  ej                          ZddZ e       Z G d	 d
e      Zy)    )annotationsN)IOTYPE_CHECKINGAnyCallable)RemovedInSphinx90WarningzH'sphinx.testing.path' is deprecated. Use 'os.path' or 'pathlib' instead.   )
stacklevelc                 Z    t        j                  d      } t        j                  |        | S )zGet current umask valuer   )osumask)r   s    5/usr/lib/python3/dist-packages/sphinx/testing/path.pygetumaskr      s    HHQKEHHUOL    c                      e Zd ZdZdZedd       ZddZddZddZ	ddZ
ddZdd	Zdd
Zdd dZd!d"dZd#dZeZd$dZd%dZd&dZd'd(dZd)d*dZd)d+dZd,dZd!d-dZddZddZd.d/dZd0dZd1dZexZZ d fdZ! xZ"S )2pathz8
    Represents a path which behaves like a string.
     c                ^    | j                  t        j                  j                  |             S )zH
        The name of the directory the file or directory is in.
        )	__class__r   r   dirnameselfs    r   parentzpath.parent'   s     
 ~~bggood344r   c                @    t         j                  j                  |       S N)r   r   basenamer   s    r   r   zpath.basename.   s    ww%%r   c                ^    | j                  t        j                  j                  |             S )z,
        Returns the absolute path.
        )r   r   r   abspathr   s    r   r   zpath.abspath1   s      ~~bggood344r   c                @    t         j                  j                  |       S )z;
        Returns ``True`` if the path is absolute.
        )r   r   isabsr   s    r   r    z
path.isabs7        ww}}T""r   c                @    t         j                  j                  |       S )z>
        Returns ``True`` if the path is a directory.
        )r   r   isdirr   s    r   r#   z
path.isdir=   r!   r   c                @    t         j                  j                  |       S )z9
        Returns ``True`` if the path is a file.
        )r   r   isfiler   s    r   r%   zpath.isfileC        ww~~d##r   c                @    t         j                  j                  |       S )zB
        Returns ``True`` if the path is a symbolic link.
        )r   r   islinkr   s    r   r(   zpath.islinkI   r&   r   c                @    t         j                  j                  |       S )z@
        Returns ``True`` if the path is a mount point.
        )r   r   ismountr   s    r   r*   zpath.ismountO   s     wwt$$r   c                4    t        j                  | ||       y)al  
        Removes the file or directory and any files or directories it may
        contain.

        :param ignore_errors:
            If ``True`` errors are silently ignored, otherwise an exception
            is raised in case an error occurs.

        :param onerror:
            A callback which gets called with the arguments `func`, `path` and
            `exc_info`. `func` is one of :func:`os.listdir`, :func:`os.remove`
            or :func:`os.rmdir`. `path` is the argument to the function which
            caused it to fail and `exc_info` is a tuple as returned by
            :func:`sys.exc_info`.
        )ignore_errorsonerrorN)shutilrmtree)r   r,   r-   s      r   r/   zpath.rmtreeU   s      	d-Ir   c                r   t        j                  | ||       t        j                  j	                  d      rt        j
                  |      D ]g  \  }}}t        j                  |dt         z         |D ]>  }t        j                  t        j                  j                  ||      dt         z         @ i yy)a~  
        Recursively copy a directory to the given `destination`. If the given
        `destination` does not exist it will be created.

        :param symlinks:
            If ``True`` symbolic links in the source tree result in symbolic
            links in the destination tree otherwise the contents of the files
            pointed to by the symbolic links are copied.
        )symlinksSPHINX_READONLY_TESTDIRi  i  N)
r.   copytreer   environgetwalkchmodUMASKr   join)r   destinationr1   root_dirsfilesnames          r   r3   zpath.copytreeg   s     	kH=::>>34 ')ggk&: G"eUuv~.! GDHHRWW\\$5uv~FGG 5r   c                0    t        j                  | |       y)z
        Recursively move the file or directory to the given `destination`
        similar to the  Unix "mv" command.

        If the `destination` is a file it may be overwritten depending on the
        :func:`os.rename` semantics.
        N)r.   move)r   r:   s     r   movetreezpath.movetree}   s     	D+&r   c                .    t        j                  |        y)z!
        Removes a file.
        N)r   unlinkr   s    r   rC   zpath.unlink   s     			$r   c                ,    t        j                  |       S )z-
        Returns a stat of the file.
        )r   statr   s    r   rE   z	path.stat   s     wwt}r   c                0    t        j                  | |       y r   )r   utime)r   args     r   rG   z
path.utime   s    
sr   c                    t        | |fi |S r   )open)r   modekwargss      r   rJ   z	path.open   s    D$)&))r   c                n    t        | dfd|i|5 }|j                  |       ddd       y# 1 sw Y   yxY w)z6
        Writes the given `text` to the file.
        wencodingNrJ   write)r   textrO   rL   fs        r   
write_textzpath.write_text   s:     $9h9&9 	QGGDM	 	 	s   +4c                j    t        | fd|i|5 }|j                         cddd       S # 1 sw Y   yxY w)z/
        Returns the text in the file.
        rO   NrJ   read)r   rO   rL   rS   s       r   	read_textzpath.read_text   s6     $44V4 	668	 	 	s   )2c                h    t        | d      5 }|j                         cddd       S # 1 sw Y   yxY w)z0
        Returns the bytes in the file.
        rbrK   NrV   )r   rS   s     r   
read_byteszpath.read_bytes   s.     $T" 	a668	 	 	s   (1c                x    |rd}nd}t        | |      5 }|j                  |       ddd       y# 1 sw Y   yxY w)z
        Writes the given `bytes` to the file.

        :param append:
            If ``True`` given `bytes` are added at the end of the file.
        abwbr[   NrP   )r   bytesappendrK   rS   s        r   write_byteszpath.write_bytes   s=     DD$T" 	aGGEN	 	 	s   09c                @    t         j                  j                  |       S )z5
        Returns ``True`` if the path exist.
        )r   r   existsr   s    r   rd   zpath.exists   r&   r   c                @    t         j                  j                  |       S )zb
        Returns ``True`` if the path exists unless it is a broken symbolic
        link.
        )r   r   lexistsr   s    r   rf   zpath.lexists   s    
 wwt$$r   c                4    t        j                  | ||       y)z1
        Recursively create directories.
        )exist_okN)r   makedirs)r   rK   rh   s      r   ri   zpath.makedirs   s     	D$2r   c           	         | j                  t        j                  j                  | gt	        | j                   |             S )zP
        Joins the path with the argument given and returns the result.
        )r   r   r   r9   map)r   argss     r   joinpathzpath.joinpath   s0     ~~bggll4L#dnnd2KLMMr   c                ,    t        j                  |       S r   )r   listdirr   s    r   ro   zpath.listdir   s    zz$r   c                T    | j                   j                   dt        |           dS )N())r   __name__super__repr__)r   r   s    r   ru   zpath.__repr__   s*    ..))*!EG,<,>+?qAAr   )returnr   )rv   str)rv   bool)FN)r,   rx   r-   zCallable | Nonerv   None)F)r:   rw   r1   rx   rv   ry   )r:   rw   rv   ry   )rv   ry   )rv   r   )rH   r   rv   ry   )r)rK   rw   rL   r   rv   r   )zutf-8)rR   rw   rO   rw   rL   r   rv   ry   )rO   rw   rL   r   rv   rw   )rv   zbuiltins.bytes)r`   rw   ra   rx   rv   ry   )i  F)rK   intrh   rx   rv   ry   )rl   r   rv   r   )rv   z	list[str])#rs   
__module____qualname____doc__	__slots__propertyr   r   r   r    r#   r%   r(   r*   r/   r3   rA   r@   rC   rE   rG   rJ   rT   rX   r\   rb   rd   rf   ri   rm   ro   __div____truediv__ru   __classcell__)r   s   @r   r   r       s     I5 5&5##$$%J$G,' D*$%3N  %$GkB Br   r   )rv   r{   )
__future__r   r   r.   syswarningstypingr   r   r   r   sphinx.deprecationr   builtinswarngetfilesystemencodinggetdefaultencodingFILESYSTEMENCODINGr   r8   rw   r   r   r   r   <module>r      s}    " 	  
  3 3 7  4&16 /S..0L4JC4J4J4L  	
}B3 }Br   