a �DOg��@sTddlZddlZddlZddgZGdd�de�ZGdd�d�ZedkrPee��dS)�N�netrc�NetrcParseErrorc@seZdZddd�Zdd�ZdS)rNcCs"||_||_||_t�||�dS)N)�filename�lineno�msg� Exception�__init__)�selfrrr�r �/usr/lib64/python3.9/netrc.pyr szNetrcParseError.__init__cCsd|j|j|jfS)Nz%s (%s, line %s))rrr)r r r r �__str__szNetrcParseError.__str__)NN)�__name__� __module__� __qualname__rr r r r r r s c@s.eZdZd dd�Zdd�Zdd�Zdd �ZdS) rNcCsl|du}|dur&tj�tj�d�d�}i|_i|_t|��}|�|||�Wd�n1s^0YdS)N�~z.netrc)�os�path�join� expanduser�hosts�macros�open�_parse)r �file� default_netrc�fpr r r rs znetrc.__init__cCs�t�|�}|jd7_|j�dd�|_|j}|��}}|sD�q�n�|ddkrt|j|kr(t|�dkr(|j��q(n�|dkr�|��}nt|dkr�d}nf|dkr�|��}g|j |<d |_ |j��} | r�| d kr�d |_ q(|j |� | �q�q(nt d |||j��d} d} } i|j |<|��}|�d��s.|d v�rr| �rR| | | f|j |<|�|�q(nt d||t|�f||j���q|dk�s�|dk�r�|��} �q|dk�r�|��} �q|dk�r�tjdk�r�|�r�t�|���} | jt��k�rlddl}z|�| j�d}Wnt�yd| j}Yn0z|�t���d}Wn t�yTdt��}Yn0t d||f||j��| jtjtjB@�r�t d||j��|��} nt d|||j���qq(dS)Nz !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~�#�r��machine�default�macdefz � z zbad toplevel token %r>rrr r!z&malformed %s entry %s terminated by %s�login�user�account�password�posixzuid %sz9~/.netrc file owner (%s) does not match current user (%s)zY~/.netrc access too permissive: access permissions must restrict access to only the ownerzbad follower token %r)�shlexZ wordcharsZ commenters�replacerZ get_token�lenZinstream�readliner� whitespace�appendrr� startswithZ push_token�reprr�name�fstat�fileno�st_uid�getuid�pwd�getpwuid�KeyError�st_mode�stat�S_IRWXG�S_IRWXO)r rrrZlexerZ saved_linenoZtoplevel�ttZ entryname�liner#r%r&Zpropr5Zfownerr$r r r r s�         �  �  ��    ��� �z netrc._parsecCs0||jvr|j|Sd|jvr(|jdSdSdS)Nr )r)r �hostr r r �authenticatorsqs     znetrc.authenticatorscCs�d}|j��D]X}|j|}|d|�d|d�d�7}|drR|d|d�d�7}|d|d �d�7}q|j��D]4}|d |�d�7}|j|D] }||7}q�|d7}qr|S) Nrzmachine z login rr"rz account z password �zmacdef )r�keysr)r Zrepr>�attrsZmacror=r r r �__repr__zs   znetrc.__repr__)N)r rrrrr?rCr r r r rs Q �__main__) rr(r9�__all__rrrr �printr r r r �s  t