o
    Ni                     @  s   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	 d dl
mZ er2d dlZd dlmZ ejdedd e pAe ZdddZe ZG dd deZdS )    )annotationsN)IOTYPE_CHECKINGAny)RemovedInSphinx90Warning)CallablezH'sphinx.testing.path' is deprecated. Use 'os.path' or 'pathlib' instead.   )
stacklevelreturnintc                  C  s   t d} t |  | S )zGet current umask valuer   )osumask)r    r   G/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/testing/path.pygetumask   s   

r   c                      s8  e Zd ZdZdZedQddZdRddZdQd	d
ZdSddZ	dSddZ
dSddZdSddZdSddZ		dTdUddZdVdWd d!ZdXd"d#ZeZdYd$d%ZdZd'd(Zd[d*d+Zd\d]d0d1Zd^d_d5d6Zd^d`d7d8Zdad:d;ZdVdbd>d?ZdSd@dAZdSdBdCZdcdddGdHZdedJdKZdfdMdNZe ZZ dR fdOdPZ!  Z"S )gpathz8
    Represents a path which behaves like a string.
    r   r
   c                 C     |  tj| S )zH
        The name of the directory the file or directory is in.
        )	__class__r   r   dirnameselfr   r   r   parent*   s   zpath.parentstrc                 C     t j| S N)r   r   basenamer   r   r   r   r   1   s   zpath.basenamec                 C  r   )z,
        Returns the absolute path.
        )r   r   r   abspathr   r   r   r   r   4   s   zpath.abspathboolc                 C  r   )z;
        Returns ``True`` if the path is absolute.
        )r   r   isabsr   r   r   r   r   :      z
path.isabsc                 C  r   )z>
        Returns ``True`` if the path is a directory.
        )r   r   isdirr   r   r   r   r    @   r   z
path.isdirc                 C  r   )z9
        Returns ``True`` if the path is a file.
        )r   r   isfiler   r   r   r   r!   F   r   zpath.isfilec                 C  r   )zB
        Returns ``True`` if the path is a symbolic link.
        )r   r   islinkr   r   r   r   r"   L   r   zpath.islinkc                 C  r   )z@
        Returns ``True`` if the path is a mount point.
        )r   r   ismountr   r   r   r   r#   R   r   zpath.ismountFNignore_errorsonerror7Callable[[Callable[..., Any], str, Any], object] | NoneNonec                 C     t j| ||d dS )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`.
        )r$   r%   N)shutilrmtree)r   r$   r%   r   r   r   r*   X   s   zpath.rmtreedestinationsymlinksc                 C  sr   t j| ||d tjdr5t|D ]#\}}}t|dt @  |D ]}ttj	||dt @  q#qdS dS )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.
        )r,   SPHINX_READONLY_TESTDIRi  i  N)
r)   copytreer   environgetwalkchmodUMASKr   join)r   r+   r,   root_dirsfilesnamer   r   r   r.   n   s   
zpath.copytreec                 C  s   t | | dS )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+   r   r   r   movetree   s   zpath.movetreec                 C  s   t |  dS )z!
        Removes a file.
        N)r   unlinkr   r   r   r   r;      s   zpath.unlinkr   c                 C  
   t | S )z-
        Returns a stat of the file.
        )r   statr   r   r   r   r=      s   
z	path.statargc                 C  s   t | | d S r   )r   utime)r   r>   r   r   r   r?      s   z
path.utimermodekwargsIO[str]c                 K  s   t | |fi |S r   )open)r   rA   rB   r   r   r   rD      s   z	path.openutf-8textencodingc                 K  sF   t | dfd|i|}|| W d   dS 1 sw   Y  dS )z6
        Writes the given `text` to the file.
        wrG   NrD   write)r   rF   rG   rB   fr   r   r   
write_text   s   "zpath.write_textc                 K  s@   t | fd|i|}| W  d   S 1 sw   Y  dS )z/
        Returns the text in the file.
        rG   NrD   read)r   rG   rB   rK   r   r   r   	read_text   s   $zpath.read_textbuiltins.bytesc                 C  s8   t | dd}| W  d   S 1 sw   Y  dS )z0
        Returns the bytes in the file.
        rbrA   NrM   )r   rK   r   r   r   
read_bytes   s   $zpath.read_bytesbytesappendc                 C  sJ   |rd}nd}t | |d}|| W d   dS 1 sw   Y  dS )z
        Writes the given `bytes` to the file.

        :param append:
            If ``True`` given `bytes` are added at the end of the file.
        abwbrR   NrI   )r   rT   rU   rA   rK   r   r   r   write_bytes   s   "zpath.write_bytesc                 C  r   )z5
        Returns ``True`` if the path exist.
        )r   r   existsr   r   r   r   rY      r   zpath.existsc                 C  r   )zb
        Returns ``True`` if the path exists unless it is a broken symbolic
        link.
        )r   r   lexistsr   r   r   r   rZ      s   zpath.lexists  r   exist_okc                 C  r(   )z1
        Recursively create directories.
        )r\   N)r   makedirs)r   rA   r\   r   r   r   r]      s   zpath.makedirsargsc                 G  s"   |  tjj| gt| j |R  S )zP
        Joins the path with the argument given and returns the result.
        )r   r   r   r4   map)r   r^   r   r   r   joinpath   s   "zpath.joinpath	list[str]c                 C  r<   r   )r   listdirr   r   r   r   rb      s   
zpath.listdirc                   s   | j j dt   dS )N())r   __name__super__repr__r   r   r   r   rg      s   zpath.__repr__)r
   r   )r
   r   )r
   r   )FN)r$   r   r%   r&   r
   r'   )F)r+   r   r,   r   r
   r'   )r+   r   r
   r'   )r
   r'   )r
   r   )r>   r   r
   r'   )r@   )rA   r   rB   r   r
   rC   )rE   )rF   r   rG   r   rB   r   r
   r'   )rG   r   rB   r   r
   r   )r
   rP   )rT   rT   rU   r   r
   r'   )r[   F)rA   r   r\   r   r
   r'   )r^   r   r
   r   )r
   ra   )#re   
__module____qualname____doc__	__slots__propertyr   r   r   r   r    r!   r"   r#   r*   r.   r:   r9   r;   r=   r?   rD   rL   rO   rS   rX   rY   rZ   r]   r`   rb   __div____truediv__rg   __classcell__r   r   rh   r   r   #   sB    
















r   )r
   r   )
__future__r   r   r)   syswarningstypingr   r   r   sphinx.deprecationr   builtinscollections.abcr   warngetfilesystemencodinggetdefaultencodingFILESYSTEMENCODINGr   r3   r   r   r   r   r   r   <module>   s&    
