Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/netrc.cpython-34.pyo
�
f ft�@sdZddlZddlZddlZddgZGdd�de�ZGdd�d�Zedkr{e e��ndS)z-An object-oriented interface to .netrc files.�N�netrc�NetrcParseErrorc@s4eZdZdZdddd�Zdd�ZdS)rz5Exception raised on syntax errors in the .netrc file.NcCs/||_||_||_tj||�dS)N)�filename�lineno�msg� Exception�__init__)�selfrrr�r
�*/opt/alt/python34/lib64/python3.4/netrc.pyrs zNetrcParseError.__init__cCsd|j|j|jfS)Nz%s (%s, line %s))rrr)r r
r
r�__str__szNetrcParseError.__str__)�__name__�
__module__�__qualname__�__doc__rrr
r
r
rr
sc@sCeZdZddd�Zdd�Zdd�Zdd �ZdS)
rNcCs�|dk}|dkr\y tjjtjdd�}Wq\tk
rXtd��Yq\Xni|_i|_t|��}|j |||�WdQXdS)N�HOMEz.netrcz'Could not find .netrc: $HOME is not set)
�os�path�join�environ�KeyError�OSError�hosts�macros�open�_parse)r �file�
default_netrc�fpr
r
rrs
znetrc.__init__cCs�tj|�}|jd7_|jjdd�|_xk|j}|j�}}|s\Pn|ddkr�|j|kr9t|�dkr9|jj�q9q9n�|dkr�|j�}n�|dkr�d}n�|dkrQ|j�}g|j |<d |_
xG|jj�} | s&| d
kr3d|_
Pn|j |j| �qWq9ntd|||j��d}
d}}i|j
|<x|j�}|jd�s�|dkr |r�|
||f|j
|<|j|�Pq�td
||t|�f||j��q�|dks!|dkr0|j�}
q�|dkrK|j�}q�|dkr�tjdkrt|rttj|j��}
|
jtj�krBddl}y|j|
j�d}Wntk
r�d|
j}YnXy|jtj��d}Wn"tk
rdtj�}YnXtd||f||j��n|
jtjtjB@rttd||j��qtn|j�}q�td|||j��q�Wq9WdS)Nz !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~�#�r��machine�default�macdefz �
z
zbad toplevel token %rz&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>r r$�machine�default)�shlexZ wordcharsZ
commenters�replacerZ get_token�lenZinstream�readlinerZ
whitespace�appendrr�
startswithZ
push_token�reprr�name�fstat�fileno�st_uid�getuid�pwd�getpwuidr�st_mode�stat�S_IRWXG�S_IRWXO)r rrrZlexerZsaved_linenoZtoplevelZttZ entryname�liner&r(r)Zpropr9Zfownerr'r
r
rr#s� !
znetrc._parsecCs<||jkr|j|Sd|jkr4|jdSdSdS)z8Return a (user, account, password) tuple for given host.r#N)r)r �hostr
r
r�authenticatorsts
znetrc.authenticatorscCs�d}x�|jj�D]x}|j|}|d|dt|d�d}|drr|dt|d�}n|dt|d �d}qWxU|jj�D]D}|d
|d}x|j|D]}||}q�W|d}q�W|S)z3Dump the class data in the format of a .netrc file.r zmachine z
login rr%r!zaccount z
password �zmacdef )r�keysr3r)r Zrepr@ZattrsZmacror?r
r
r�__repr__}s
$
znetrc.__repr__)r
rrrrrArDr
r
r
rrsQ �__main__)
rrr-r<�__all__rrrr
�printr
r
r
r�<module>s$w