Mini Shell
a
�DOg9� � @ sb d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm Z d dl
mZmZm
Z
mZmZ d dlmZ d dlmZmZmZmZmZmZmZ d dlmZ dZejdkr�d dlZe� � dd � d
kr�d dlm!Z! q�dZdZ!ndZg d
�Z"ee
eefZ#dZ$dd� Z%dd� Z&G dd� de'�Z(G dd� de(�Z)G dd� de(�Z*e)� Z+e*� Z,G dd� d�Z-G dd� de-�Z.e.� Z/dd� Z0e1ed��r�e�2� e0�Z0G d d!� d!�Z3G d"d#� d#�Z4G d$d%� d%e3�Z5G d&d'� d'e3�Z6G d(d)� d)e3�Z7G d*d+� d+e �Z8G d,d-� d-e'�Z9ej:�;e9� G d.d/� d/e9�Z<G d0d1� d1e9�Z=G d2d3� d3e9�Z>G d4d5� d5e>e<�Z?G d6d7� d7e>e=�Z@dS )8� N)�Sequence)�EINVAL�ENOENT�ENOTDIR�EBADF�ELOOP)�
attrgetter)�S_ISDIR�S_ISLNK�S_ISREG�S_ISSOCK�S_ISBLK�S_ISCHR�S_ISFIFO)�quote_from_bytesT�nt� )� r )�_getfinalpathnameF)�PurePath�
PurePosixPath�PureWindowsPath�Path� PosixPath�WindowsPath)� �{ i� c C s t | dd �tv pt | dd �tv S )N�errno�winerror)�getattr�_IGNORED_ERROS�_IGNORED_WINERRORS)� exception� r# �/usr/lib64/python3.9/pathlib.py�
_ignore_error. s �r% c C s d| v pd| v pd| v S )N�*�?�[r# )�patr# r# r$ �_is_wildcard_pattern3 s r* c @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) �_FlavourzPA flavour implements a particular (platform-specific) set of path
semantics.c C s | j j| _d S �N)�sep�join��selfr# r# r$ �__init__= s z_Flavour.__init__c C s g }| j }| j}d }}t|�}|D ]�}|s.q$|r>|�||�}| �|�\}}} || v r�t| �|��D ] }
|
rd|
dkrd|�t�|
�� qdn| r�| dkr�|�t�| �� |s�|r$|s�|D ]0}|s�q�|r�|�||�}| �|�d }|r� q�q� q�q$|s�|�r|�|| � |� � |||fS )N� �.r )
r- �altsep�reversed�replace� splitroot�split�append�sys�intern�reverse)r0 �parts�parsedr- r4 �drv�root�it�part�rel�xr# r# r$ �parse_parts@ s@
z_Flavour.parse_partsc C sz |r*|sp|rp|||| g|dd� fS nF|rb||ksJ| � |�| � |�krp||||dd� fS n|||| fS |||fS )z�
Join the two paths represented by the respective
(drive, root, parts) tuples. Return a new (drive, root, parts) tuple.
� N)�casefold)r0 r? r@ r= �drv2�root2�parts2r# r# r$ �join_parsed_partsf s z_Flavour.join_parsed_partsN)�__name__�
__module__�__qualname__�__doc__r1 rE rK r# r# r# r$ r+ 9 s &r+ c @ s� e Zd ZdZdZdZeZej dkZ
ed�ZdZ
h d�dd � d
D �B dd � d
D �B Zefdd
�Zdd� Zdd� Zdd� Zd"dd�Ze
fdd�Zdd� Zdd� Zdd� Zdd � Zd!S )#�_WindowsFlavour�\�/Tr Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\> zCONOUT$�PRN�AUX�CONzCONIN$�NULc C s h | ]}d | �qS )zCOM%sr# ��.0�cr# r# r$ � <setcomp>� � z_WindowsFlavour.<setcomp>u 123456789¹²³c C s h | ]}d | �qS )zLPT%sr# rW r# r# r$ rZ � r[ c C s\ |dd� }|dd� }||krP||krP| � |�\}}|dd� }|dd� }nd}|dd� }||kr�||kr�||kr�|�|d�}|dkr�|�||d �}||d kr�|dkr�t|�}|r�||d|� |||d d � fS |d |� |||d d � fS d } }
|dk�r6|| jv �r6|d d� } |dd � }|}||k�rN|}
|�|�}|| |
|fS )Nr rF r r2 � ����:)�_split_extended_path�find�len�
drive_letters�lstrip)r0 rB r- �first�second�prefix�third�index�index2r? r@ r# r# r$ r7 � s6 "
z_WindowsFlavour.splitrootc C s |� � S r, ��lower�r0 �sr# r# r$ rG � s z_WindowsFlavour.casefoldc C s dd� |D �S )Nc S s g | ]}|� � �qS r# rj )rX �pr# r# r$ �
<listcomp>� r[ z2_WindowsFlavour.casefold_parts.<locals>.<listcomp>r# �r0 r= r# r# r$ �casefold_parts� s z_WindowsFlavour.casefold_partsc C s t �t�|�t j�jS r, )�re�compile�fnmatch� translate�
IGNORECASE� fullmatch�r0 �patternr# r# r$ �compile_pattern� s z_WindowsFlavour.compile_patternFc C s� t |�}|st�� S d }td ur�|r2| �t|��S g }z| �t|��}W n@ ty� |}tj�|�\}}|�|� ||kr�| Y S Y q60 tjj |gt
|��R � S q6d S r, )�str�os�getcwdr �_ext_to_normal�FileNotFoundError�pathr8 r9 r. r5 )r0 r� �strictrm �
previous_s�
tail_parts�tailr# r# r$ �resolve� s$
z_WindowsFlavour.resolvec C sX d}|� |�rP|d d� }|dd � }|� d�rP||d d� 7 }d|dd � }||fS )Nr2 � zUNC\r\ rQ )�
startswith)r0 rm �
ext_prefixrf r# r# r$ r_ � s
z$_WindowsFlavour._split_extended_pathc C s | � |�d S �NrF )r_ rl r# r# r$ r~ � s z_WindowsFlavour._ext_to_normalc C sJ |sdS |d � d�rdS |d �d�d �d�d �d�}|�� | jv S )NFr z\\r] r3 r^ � )r� � partition�rstrip�upper�reserved_names)r0 r= �namer# r# r$ �is_reserved� s "z_WindowsFlavour.is_reservedc C sd |j }t|�dkrJ|d dkrJ|�� dd � �d�}d|t|�d��f S dt|�� �d�� S d S )Nr rF r^ rR z
file:///%s/%szutf-8zfile:)�drivera �as_posixrc �urlquote_from_bytes�encode)r0 r� r� �restr# r# r$ �make_uri� s �z_WindowsFlavour.make_uric C s� dt jv rt jd }nHdt jv rVzt jd }W n tyD d}Y n0 |t jd }ntd��|r�t jd |kr�| �|f�\}}}|d t jd kr�td| ��||d<