� c��j�C��d�dZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l �gd �Z d �Zd �Zd �Zd�Zd�Zd�Ze j(je_d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdZdadad�Z ddl!m"Z#d�Z%dd�d �Z&d!�Z'e jPd"k(Z)d%d#�Z*d$�Z+y#e$$rd�Z#Y�-wxYw)&a�Common operations on Posix pathnames. Instead of importing this module directly, import os and refer to this module as os.path. The "os.path" name is an alias for this module on Posix systems; on other systems (e.g. Windows), os.path provides the same operations in a manner specific to that platform, and is an alias to another module (e.g. ntpath). Some of this can actually be useful on non-Posix systems too, e.g. for manipulation of the pathname component of URLs. �.�..�/�:z /bin:/usr/binNz /dev/null�)�*))�normcase�isabs�join� splitdrive� splitroot�split�splitext�basename�dirname� commonprefix�getsize�getmtime�getatime�getctime�islink�exists�lexists�isdir�isfile�ismount� expanduser� expandvars�normpath�abspath�samefile� sameopenfile�samestat�curdir�pardir�sep�pathsep�defpath�altsep�extsep�devnull�realpath�supports_unicode_filenames�relpath� commonpath� isjunction� ALLOW_MISSINGc�&�t|t�ryy)N�/r)� isinstance�bytes��paths �"/usr/lib64/python3.12/posixpath.py�_get_sepr8)s���$�����c�,�tj|�S)z6Normalize case of pathname. Has no effect under Posix��os�fspath)�ss r7rr4s�� �9�9�Q�<�r9c�d�tj|�}t|�}|j|�S)zTest whether a path is absolute)r<r=r8� startswith)r>r%s r7r r <s'�� � � �!� �A� �1�+�C� �<�<�� �r9c�j�tj|�}t|�}|} |s|dd|zttj|�D]7}|j |�r|}�|r|j |�r||z }�0|||zz }�9 |S#t ttf$rtjd|g|����wxYw)z�Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.Nrr ) r<r=r8�mapr@�endswith� TypeError�AttributeError� BytesWarning� genericpath�_check_arg_types)�a�pr%r6�bs r7r r Gs��� � � �!� �A� �1�+�C� �D� �� ��!�H�s�N��R�Y�Y��"�A��|�|�C� ����T�]�]�3�/��� ����a���� #� �K�� �~�|� 4���$�$�V�Q�3��3� ��s �AB�-B2c���tj|�}t|�}|j|�dz}|d|||d}}|r"||t |�zk7r|j |�}||fS)z�Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.�N�r<r=r8�rfind�len�rstrip)rJr%�i�head�tails r7r r dsk�� � � �!� �A� �1�+�C� ���� �q��A��2�A���!�"��$�D� ���C��I� �%��{�{�3��� ��:�r9c��tj|�}t|t�rd}d}nd}d}t j ||d|�S)Nr2�.rr)r<r=r3r4rG� _splitext)rJr%r)s r7rrusD�� � � �!� �A��!�U���������� � � ��C��v� 6�6r9c�:�tj|�}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr;)rJs r7r r �s �� � � �!� �A� �R�a�5�!�8�Or9c��tj|�}t|t�rd}d}nd}d}|dd|k7r|||fS|dd|k7s|dd|k(r|||ddfS||dd|ddfS) a�Split a pathname into drive, root and tail. On Posix, drive is always empty; the root may be empty, a single slash, or two slashes. The tail contains anything after the root. For example: splitroot('foo/bar') == ('', '', 'foo/bar') splitroot('/foo/bar') == ('', '/', 'foo/bar') splitroot('//foo/bar') == ('', '//', 'foo/bar') splitroot('///foo/bar') == ('', '/', '//foo/bar') r2r9r�NrM��)r<r=r3r4)rJr%�emptys r7r r �s��� � � �!� �A��!�U������������!�u��|��e�Q��� �1�Q��3��!�A�a�&�C�-��c�1�Q�R�5� � ��a���e�Q�q�r�U�"�"r9c�t�tj|�}t|�}|j|�dz}||dS)z)Returns the final component of a pathnamerMN)r<r=r8rO)rJr%rRs r7rr�s5�� � � �!� �A� �1�+�C� ���� �q��A� �Q�R�5�Lr9c���tj|�}t|�}|j|�dz}|d|}|r"||t |�zk7r|j |�}|S)z-Returns the directory component of a pathnamerMNrN)rJr%rRrSs r7rr�sZ�� � � �!� �A� �1�+�C� ���� �q��A� �R�a�5�D� ���C��I� �%��{�{�3��� �Kr9c�.�tj|�y)zQTest whether a path is a junction Junctions are not a part of posix semanticsFr;r5s r7r/r/�s���I�I�d�O� r9c�Z� tj|�y#ttf$rYywxYw)zCTest whether a path exists. Returns True for broken symbolic linksFT)r<�lstat�OSError� ValueErrorr5s r7rr�s0��� ����� �� �Z� ����s ��*�*c��� tj|�}tj|j�rytj|�}t|t�r t|d�}n t|d�}t|�} tj|�}|j}|j}||k7ry|j}|j}||k(ryy#t t f$rYywxYw#t t f$rYywxYw)z$Test whether a path is a mount pointF�..rT)r<rb�stat�S_ISLNK�st_modercrdr=r3r4r r+�st_dev�st_ino)r6�s1�parent�s2�dev1�dev2�ino1�ino2s r7rr�s���� �X�X�d�^�� �<�<�� � � #�� �9�9�T�?�D��$����d�E�"���d�D�!�� �f� �F�� �X�X�f� �� �9�9�D� �9�9�D� �t�|�� �9�9�D� �9�9�D� �t�|�� ��7 �Z� ����� �Z� ����s#�C�C(�C%�$C%�(C:�9C:c�r�tj|�}t|t�rd}nd}|j |�s|St |�}|j |d�}|dkr t|�}|dk(rZdtjvr4 ddl } |jtj��j}natjd}nM ddl }|d|}t|t�rtj|�} |j!|�}|j}|�t"j$dk(r|St|t�rtj&|�}d}nd }|j)|�}|||dzxs|S#t$r|cYSwxYw#t$r|cYSwxYw#t$r|cYSwxYw#t$r|cYSwxYw) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.�~�~rMr�HOMEN�vxworksr2r)r<r=r3r4r@r8�findrP�environ�pwd� ImportError�getpwuid�getuid�pw_dir�KeyError�fsdecode�getpwnam�sys�platform�fsencoderQ) r6�tilder%rRrz�userhome�name�pwent�roots r7rrs��� �9�9�T�?�D��$������� �?�?�5� !�� � �4�.�C� � � �#�q��A��1�u� ��I���A�v� ���� #� �� ��<�<�� � � �4�;�;�� �z�z�&�)�H� � ��A�a�y�� �d�E� "��;�;�t�$�D� ��L�L��&�E� �<�<����C�L�L�I�5�� ��$����;�;�x�(���������t�$�H� �t�A�B�x� � (�D�(��I� �� � �� � �� � ��� ��K� ��� ��K� �sH�E5�-F� F�:F(�5 F�F� F�F� F%�$F%�( F6�5F6z\$(\w+|\{[^}]*\}?)c������tj|�}t|t�rdd|vr|Sts.repl[s������t�� �?�?�5� !��=�=��%���t� ���"�:�D� ���� � �B�J�J�r�{�{�4�/@�$A�B�� �L�  �� ���L��� ��Q�4�K� �s�;A9�1A9�9B � B )r<r=r3r4�_varsubb�re�compile� _varpattern�encode�ASCII�sub�getattr�_varsubry)r6r�r�r�r�ryr�s @@@r7rrAs���� �9�9�T�?�D��$��� �t� ��K�� ��z�z�+�"4�"4�"6����A�E�E�H��������"�j�$�/�� �d�?��K�� ��j�j��b�h�h�7�;�;�G��������*�*��� �t�T�?�r9)�_path_normpathc��tj|�}t|t�r d}d}d}d}nd}d}d}d}||k(r|St |�\}}}|j |�}g}|D]A} | ||fvr� | |k7s|s|r |r|d |k(r|j | ��/|s�2|j��C|}||j|�z}|xs|S) z0Normalize path, eliminating double slashes, etc.r2r9rVrfrrZrrr�) r<r=r3r4r r �append�popr ) r6r%r]�dot�dotdot�_�initial_slashes�comps� new_comps�comps r7rrvs����y�y���� �d�E� "��C��E��C��F��C��E��C��F� �5�=��J�#,�T�?� ��?�D�� � �3���� ��D���s�|�#������y�� �"� �� 7�� � ��&��� � ���������%��0���{�s�r9c���tj|�}t|�sEt|t�rtj �}ntj �}t||�}t|�S)zReturn an absolute path.) r<r=r r3r4�getcwdb�getcwdr r)r6�cwds r7rr�sK�� �9�9�T�?�D� ��;� �d�E� "��*�*�,�C��)�)�+�C��C���� �D�>�r9F)�strictc�j�tj|�}t|dd||i�\}}t|�S)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r<r=� _joinrealpathr)�filenamer�r6�oks r7r+r+�s6���y�y��"�H��X�b�q�\�8�V�R�@�H�D�"� �4�=�r9c���t|t�rd}d}d}nd}d}d}tj}|turt }n |rd}nt }d} t|�r|dd}|}|�r|j|�\} } }| r| |k(r� | |k(r&|r!t|�\}} | |k(rt|||�}n|}�Kt|| �} tj| �} tj| j�}|s| }��| |vr.|| }|���|rtj| �nt| |�d fSd|| <t|tj | �||�\}}|st||�d fS||| <|r��|d fS#|$rd }Y��wxYw) Nr2rVrfrrr�rMFT)r3r4r<r�r0�FileNotFoundErrorrcr � partitionr r rbrgrhrir��readlink)r6�restr��seenr%r#r$r�� ignored_error�maxlinksr�r��newpath�st�is_linkr�s r7r�r��s����$������������������� ���)� � �� �� ��H� �T�{��A�B�x���� ����s�+� ��a���t�v�~� � �6�>��"�4�[� ��d��6�>���f�f�5�D��� ��t�T�"�� /����'�"�B��l�l�2�:�:�.�G���D� � �d�?���=�D��������� ��G�T�*�E�1�1���W� � ��r�{�{�7�';�V�T�J���b����d�#�U�*� *���W� �U �X ��:���7� ��G� �s�4E%�%E/�.E/�darwinc�P�|s td��tj|�}t|t�rd}d}d}nd}d}d}|�|}ntj|�} t |�j |�D�cgc]}|s�|�� }}t |�j |�D�cgc]}|s�|�� }}tt||g��}|gt|�|z z||dz} | s|St| �Scc}wcc}w#ttttf$rtjd ||��wxYw) z#Return a relative version of a pathzno path specifiedrVr2rfrrrNr-)rdr<r=r3r4rr rPrr rDrErF�DeprecationWarningrGrH) r6r�r#r%r$�x� start_list� path_listrR�rel_lists r7r-r-�s2�� ��,�-�-� �9�9�T�?�D��$��������������� �}���� � �%� �� �!(���!5�!5�c�!:�@�!:�A�a�a�!:� �@� '�� � 3� 3�C� 8�>� 8�1�A�Q� 8� �>� � �j�)�4�5� 6���8�s�:��q�0�1�I�a�b�M�A����M��X����A��>�� �~�|�5G� H���$�$�Y��e�<� ��s<�C3�7C)�?C)�C3�!C.�)C.�-3C3�!C3�) C3�32D%c �� �|s td��tttj|��}t |dt �rd� d}nd� d} |D�cgc]}|j� ���}} t� fd�|D��\}|D��cgc]}|D�cgc] }|s�||k7s� |��c}��}}}t|�}t|�}|} t|�D]\} }||| k7s�|d | } n|r� n� d d} | � j| �zScc}w#t$r td�d �wxYwcc}wcc}}w#ttf$rtj d g|����wxYw) zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr2rVrrc3�.�K�|] }|dd�k(���y�w)NrMr�)�.0rJr%s �r7� zcommonpath..0s�����5�u�!��2�A��#��u�s�z%Can't mix absolute and relative pathsNr.)rd�tuplerBr<r=r3r4r �set�min�max� enumerater rDrErGrH) �pathsr#r6� split_pathsr r>�crlrn�commonrR�prefixr%s @r7r.r.su��� ��@�A�A� �#�b�i�i��'� (�E��%��(�E�"����������38�9�5�4�t�z�z�#��5� �9� P��5�u�5�5�F�E�EP�P�K�q�1�:�1�a��a�6�k��1�:�K� �P� �� �� �� �����b�M�D�A�q��B�q�E�z��B�Q����"� ��3�r��7�������(�(�(��#:��� P��D�E�4� O� P��;��P�� �~� &���$�$�\�:�E�:� ��sl�D,�D�+D,�.D�D,� D&�D! �D! � D! �$D&�)4D,�$D,�D,�D�D,�!D&�&D,�,'E)N),�__doc__r#r$r)r%r&r'r(r*r<r�rgrG�__all__r8rr r r rrWr r rrr/rrrr�r�r�r�posixr�rr{rr+r�r�r,r-r.r�r9r7�r�s�� � �� �� �� �� �� �� �� �� � � ��� 8������: �"7��(�(�0�0��� �#�>�����V6)�z$� � �� ��*�b �0�D �"'��C�L"�l�l�h�6��!�R#��S����s�;B$�$B/�.B/