a �DOgA�@s�gd�ZddlZzddlmZWney:dd�ZYn0Gdd�de�ZeZgfdd �Zgfd d �Z d d �Z dd�Z dd�Z dd�Z edkr�ddlZeeejdd�dddg��dS))� GetoptError�error�getopt� gnu_getopt�N)�gettextcCs|S�N�)�srr�/usr/lib64/python3.9/getopt.py�_)�r c@s&eZdZdZdZddd�Zdd�ZdS)r�cCs||_||_t�|||�dSr)�msg�opt� Exception�__init__)�selfrrrrr r.szGetoptError.__init__cCs|jSr)r)rrrr �__str__3szGetoptError.__str__N)r )�__name__� __module__� __qualname__rrrrrrrr r+s rcCs�g}t|�td�kr|g}nt|�}|r�|d�d�r�|ddkr�|ddkr\|dd�}q�|d�d�r�t||ddd�||dd��\}}q$t||ddd�||dd��\}}q$||fS)Nr r�-�--��)�type�list� startswith�do_longs� do_shorts)�args� shortopts�longopts�optsrrr r8s  ((rcCs6g}g}t|t�r|g}nt|�}|�d�r>|dd�}d}ntj�d�rPd}nd}|�r.|ddkrz||dd�7}�q.|ddd�dkr�t||ddd�||dd��\}}qT|ddd�d kr�|dd kr�t||ddd�||dd��\}}qT|�r||7}�q.qT|� |d�|dd�}qT||fS) N�+rTZPOSIXLY_CORRECTFrrrr) � isinstance�strrr�os�environ�getrr�append)r r!r"r#Z prog_argsZall_options_firstrrr rcs2     ( (rcCs�z|�d�}Wnty$d}Yn 0|d|�||dd�}}t||�\}}|r�|dur�|stttd�||��|d|dd�}}n|dur�ttd�||��|�d||p�df�||fS)N�=rzoption --%s requires argumentrz%option --%s must not have an argumentrr )�index� ValueError� long_has_argsrr r*)r#rr"r �i�optarg�has_argrrr r�s  rcs��fdd�|D�}|s(ttd������|vr8d�fS�d|vrLd�fSt|�dkrjttd�����|d }|�d�}|r�|dd �}||fS) Ncsg|]}|���r|�qSr)r)�.0�o�rrr � �r z!long_has_args..zoption --%s not recognizedFr+Trzoption --%s not a unique prefixr�����)rr �len�endswith)rr"Z possibilitiesZ unique_matchr1rr4r r.�s    r.cCs�|dkr�|d|dd�}}t||�rh|dkr\|sFttd�||��|d|dd�}}|d}}nd}|�d||f�q||fS)Nr rrzoption -%s requires argumentr)� short_has_argrr r*)r#Z optstringr!r rr0rrr r�s  � rcCsXtt|��D]4}|||kr(dkr nq |�d|d�Sq ttd�||��dS)N�:rzoption -%s not recognized)�ranger7rrr )rr!r/rrr r9�sr9�__main__rza:bzalpha=�beta)�__all__r'rr � ImportErrorrrrrrrr.rr9r�sys�print�argvrrrr �"s    + 2