HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/sphinx/util/__pycache__/osutil.cpython-310.pyc
o

�$�a,�@sdZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZm
Z
mZmZmZmZddlmZzddlm
ZWneySdZYnwdZded	efd
d�Zded	efd
d�Zdeded	efdd�Zded	dfdd�Zdeeded	eefdd�Zdeded	dfdd�Zdeded	dfdd�Z deded	dfd d!�Z!e�"d"�Z#e�"d#�Z$d$ed	efd%d&�Z%d'ed	efd(d)�Z&ej'fded*ed	efd+d,�Z(e(Z)e�*�p�e�+�Z,d-ed	efd.d/�Z-ej.d0ed	e
d1fd2d3��Z/Gd4d5�d5�Z0ded	dfd6d7�Z1dS)8z�
    sphinx.util.osutil
    ~~~~~~~~~~~~~~~~~~

    Operating system-related utility functions for Sphinx.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�StringIO��path)�Any�	Generator�Iterator�List�Optional�Type)�RemovedInSphinx50Warning�/�
canonicalpath�returncCs|�ttj�S�N)�replace�SEPr�sep)r
�r�4/usr/lib/python3/dist-packages/sphinx/util/osutil.py�os_path'sr�
nativepathcCs|�tjt�S)z"Return path in OS-independent form)rrrr)rrrr�
canon_path+sr�base�tocCs�|�t�r|S|�d�d�t�}|�d�d�t�}t|dd�|dd��D]\}}||kr2n|�d�|�d�q(||krCdSt|�dkrR|dgkrRdtSdtt|�dt�|�S)	z.Return a relative URL from ``base`` to ``to``.�#rN������.z..)�
startswithr�split�zip�pop�len�join)rr�b2�t2�x�yrrr�relative_uri0s
"
r)rcCstj|dd�dS)zEnsure that a path exists.T)�exist_okN)�os�makedirsrrrr�	ensuredirGsr-�dirnames�suffixccsf�|D]-}t�|�D]%\}}}|D]}|�|�r.zt�t�||��VWqty-Yqwqq
qdSr)r+�walk�endswithr�getmtimer$�OSError)r.r/�dirname�root�dirs�files�sfilerrr�mtimes_of_filesLs�
�����r9�source�destcCsNtjdtdd�tj�|�rzt�|�Wn	tyYnwt�||�dS)z3Move a file, removing the destination if it exists.zYsphinx.util.osutil.movefile() is deprecated for removal. Please use os.replace() instead.�)�
stacklevelN)	�warnings�warnrr+r�exists�unlinkr3�rename�r:r;rrr�movefileWs��rDcCs0t�|�}ttd�rt�||j|jf�dSdS)z!Copy a file's modification times.�utimeN)r+�stat�hasattrrE�st_atime�st_mtime)r:r;�strrr�	copytimesds

�rKcCsLt�|�rt�||�s$t�||�zt||�WdSty#YdSwdS)z{Copy a file and its modification times, if possible.

    Note: ``copyfile`` skips copying if the file has not been changedN)rr@�filecmp�cmp�shutil�copyfilerKr3rCrrrrOks��rOz[^a-zA-Z0-9_-]z Documentation$�stringcCst�d|�pdS)Nr�sphinx)�no_fn_re�sub)rPrrr�
make_filename|srT�projectcCstt�d|����S)Nr)rT�project_suffix_rerS�lower)rUrrr�make_filename_from_project�srX�startcCs(ztj�||�WSty|YSw)aReturn a relative filepath to *path* either from the current directory or
    from an optional *start* directory.

    This is an alternative of ``os.path.relpath()``.  This returns original path
    if *path* and *start* are on different drives (for Windows platform).
    )r+r�relpath�
ValueError)rrYrrrrZ�s
�rZ�pathdirc
Csjtdur
t|t�r
|��St�|�}t|t�r3z|�t�}W|Sty2}ztdt�|�d}~ww|S)NzAmultibyte filename not supported on this filesystem encoding (%r))�Path�
isinstance�abspathr�bytes�decode�fs_encoding�UnicodeDecodeError)r\�excrrrr_�s 

�����r_�
target_dir)NNNc	cs8�t��}zt�|�dVWt�|�dSt�|�wr)r+�getcwd�chdir)re�cwdrrr�cd�s�
ric@sxeZdZdZdeddfdd�Zdeddfdd	�Zdd
d�Zddd
�Zde	e
de
dedefdd�Z
dedefdd�ZdS)�FileAvoidWritea�File-like object that buffers output and only writes if content changed.

    Use this class like when writing to a file to avoid touching the original
    file if the content hasn't changed. This is useful in scenarios where file
    mtime is used to invalidate caches or trigger new behavior.

    When writing to this file handle, all writes are buffered until the object
    is closed.

    Objects can be used as context managers.
    rrNcCs||_d|_dSr)�_path�_io)�selfrrrr�__init__�s
zFileAvoidWrite.__init__�datacCs|jst�|_|j�|�dSr)rlr�write)rmrorrrrp�szFileAvoidWrite.writecCs�|jstd��|��}|j��z+t|jdd��}|��}||kr+	Wd�WdSWd�n1s5wYWn	tyDYnwt|jddd��}|�|�Wd�dS1s^wYdS)z0Stop accepting writes and write file, if needed.z,FileAvoidWrite does not support empty files.zutf-8)�encodingN�w)	rl�	Exception�getvalue�close�openrk�readr3rp)rm�buf�old_f�old_content�frrrru�s&
����"�zFileAvoidWrite.closecCs|Srr)rmrrr�	__enter__�szFileAvoidWrite.__enter__�exc_type�	exc_value�	tracebackcCs|��dS)NT)ru)rmr}r~rrrr�__exit__�szFileAvoidWrite.__exit__�namecCs|jstd��t|j|�S)Nz=Must write to FileAvoidWrite before other methods can be used)rlrs�getattr)rmr�rrr�__getattr__�szFileAvoidWrite.__getattr__)rN)rrj)�__name__�
__module__�__qualname__�__doc__�strrnrprur|r
rsr�boolr�r�rrrrrj�s

rjcCs(tj�|�r
t�|�dSt�|�dSr)r+r�isdirrN�rmtree�removerrrrr��sr�)2r��
contextlibrLr+�rerN�sysr>�iorr�typingrrrrr	r
�sphinx.deprecationr�sphinx.testing.pathr]�ImportErrorrr�rrr)r-�floatr9rDrKrO�compilerRrVrTrX�curdirrZ�safe_relpath�getfilesystemencoding�getdefaultencodingrbr_�contextmanagerrirjr�rrrr�<module>sL
 �	



	8