3

T'ícã@s„ddlZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
mZejƒpZej
ƒZedœdd„ZeƒZGdd„deƒZdS)	éN)ÚIOÚAnyÚCallableÚList)ÚRemovedInSphinx50Warning)ÚreturncCstjdƒ}tj|ƒ|S)zGet current umask valuer)ÚosÚumask)r	©r
ú5/tmp/pip-build-gk9425m9/sphinx/sphinx/testing/path.pyÚgetumask
s

rcsâeZdZdZeddœdd„ƒZedœdd„Zddœdd„Ze	dœd	d
„Z
e	dœdd„Ze	dœd
d„Ze	dœdd„Z
e	dœdd„ZdHe	eddœdd„ZdIee	ddœdd„Zeddœdd„ZeZddœdd„Zedœd d!„Zedd"œd#d$„ZdJeeed&œd'd(„ZdKeeedd*œd+d,„ZdLeeed-œd.d/„ZdMeeed-œd0d1„Zejdœd2d3„Zejdœd4d5„ZdNee	dd6œd7d8„Z e	dœd9d:„Z!e	dœd;d<„Z"dOe#e	dd>œd?d@„Z$eddAœdBdC„Z%e&edœdDdE„Z'e%Z(Z)edœ‡fdFdG„Z*‡Z+S)PÚpathz8
    Represents a path which behaves like a string.
    )rcCs|jtjj|ƒƒS)zH
        The name of the directory the file or directory is in.
        )Ú	__class__rr
Údirname)Úselfr
r
rÚparentszpath.parentcCstjj|ƒS)N)rr
Úbasename)rr
r
rr$sz
path.basenamecCs|jtjj|ƒƒS)z,
        Returns the absolute path.
        )rrr
Úabspath)rr
r
rr'szpath.abspathcCstjj|ƒS)z;
        Returns ``True`` if the path is absolute.
        )rr
Úisabs)rr
r
rr-sz
path.isabscCstjj|ƒS)z>
        Returns ``True`` if the path is a directory.
        )rr
Úisdir)rr
r
rr3sz
path.isdircCstjj|ƒS)z9
        Returns ``True`` if the path is a file.
        )rr
Úisfile)rr
r
rr9szpath.isfilecCstjj|ƒS)zB
        Returns ``True`` if the path is a symbolic link.
        )rr
Úislink)rr
r
rr?szpath.islinkcCstjj|ƒS)z@
        Returns ``True`` if the path is a mount point.
        )rr
Úismount)rr
r
rrEszpath.ismountFN)Ú
ignore_errorsÚonerrorrcCstj|||ddS)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`.
        )rrN)ÚshutilÚrmtree)rrrr
r
rrKszpath.rmtree)ÚdestinationÚsymlinksrcCsvtj|||dtjjdƒrrxTtj|ƒD]F\}}}tj|dt@ƒx(|D] }tjtjj	||ƒdt@ƒqJWq(WdS)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.
        )rZSPHINX_READONLY_TESTDIRiíi¤N)
rÚcopytreerÚenvironÚgetÚwalkÚchmodÚUMASKr
Újoin)rrrÚrootZ_dirsÚfilesÚnamer
r
rr]s

z
path.copytree)rrcCstj||ƒdS)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)rrr
r
rÚmovetreessz
path.movetreecCstj|ƒdS)z!
        Removes a file.
        N)rÚunlink)rr
r
rr+szpath.unlinkcCs
tj|ƒS)z-
        Returns a stat of the file.
        )rÚstat)rr
r
rr,…sz	path.stat)ÚargrcCstj||ƒdS)N)rÚutime)rr-r
r
rr.‹sz
path.utimeÚr)ÚmodeÚkwargsrcKst||f|ŽS)N)Úopen)rr0r1r
r
rr2Žsz	path.openúutf-8)ÚtextÚencodingr1rc	Ks0t|dfd|i|—Ž}|j|ƒWdQRXdS)z6
        Writes the given `text` to the file.
        Úwr5N)r2Úwrite)rr4r5r1Úfr
r
rÚ
write_text‘szpath.write_text)r5r1rcKstjdtdd|j|f|ŽS)z/
        Returns the text in the file.
        z;Path.text() is deprecated.  Please use read_text() instead.é)Ú
stacklevel)ÚwarningsÚwarnrÚ	read_text)rr5r1r
r
rr4˜s
z	path.textc	Ks(t|fd|i|—Ž
}|jƒSQRXdS)z/
        Returns the text in the file.
        r5N)r2Úread)rr5r1r8r
r
rr> szpath.read_textcCstjdtdd|jƒS)z0
        Returns the bytes in the file.
        z=Path.bytes() is deprecated.  Please use read_bytes() instead.r:)r;)r<r=rÚ
read_bytes)rr
r
rÚbytes§s
z
path.bytesc	Cs t|dd
}|jƒSQRXdS)z0
        Returns the bytes in the file.
        Úrb)r0N)r2r?)rr8r
r
rr@¯szpath.read_bytes)rAÚappendrc	Cs4|r
d}nd}t||d}|j|ƒWdQRXdS)z—
        Writes the given `bytes` to the file.

        :param append:
            If ``True`` given `bytes` are added at the end of the file.
        ÚabÚwb)r0N)r2r7)rrArCr0r8r
r
rÚwrite_bytes¶s
zpath.write_bytescCstjj|ƒS)z5
        Returns ``True`` if the path exist.
        )rr
Úexists)rr
r
rrGÄszpath.existscCstjj|ƒS)zb
        Returns ``True`` if the path exists unless it is a broken symbolic
        link.
        )rr
Úlexists)rr
r
rrHÊszpath.lexistséÿ)r0Úexist_okrcCstj|||ddS)z1
        Recursively create directories.
        )rJN)rÚmakedirs)rr0rJr
r
rrKÑsz
path.makedirs)ÚargsrcGs |jtjj|ft|j|ƒžŽƒS)zP
        Joins the path with the argument given and returns the result.
        )rrr
r%Úmap)rrLr
r
rÚjoinpath×sz
path.joinpathcCs
tj|ƒS)N)rÚlistdir)rr
r
rrOÝszpath.listdircsd|jjtƒjƒfS)Nz%s(%s))rÚ__name__ÚsuperÚ__repr__)r)rr
rrRâsz
path.__repr__)FN)F)r/)r3)r3)r3)F)rIF),rPÚ
__module__Ú__qualname__Ú__doc__ÚpropertyrÚstrrrÚboolrrrrrrrrr*r)r+rr,r.rr2r9r4r>ÚbuiltinsrAr@rFrGrHÚintrKrNrrOZ__div__Ú__truediv__rRÚ
__classcell__r
r
)rrr
s>
r
)rYrrÚsysr<ÚtypingrrrrZsphinx.deprecationrÚgetfilesystemencodingÚgetdefaultencodingZFILESYSTEMENCODINGrZrr$rWr
r
r
r
rÚ<module>s