ó
5Þ	Pc           @   sn   d  Z  d d l Z d d l Z d d g Z d e f d „  ƒ  YZ d d d „  ƒ  YZ e d k rj e ƒ  GHn  d S(	   s-   An object-oriented interface to .netrc files.iÿÿÿÿNt   netrct   NetrcParseErrorc           B   s&   e  Z d  Z d d d „ Z d „  Z RS(   s5   Exception raised on syntax errors in the .netrc file.c         C   s/   | |  _  | |  _ | |  _ t j |  | ƒ d  S(   N(   t   filenamet   linenot   msgt	   Exceptiont   __init__(   t   selfR   R   R   (    (    s   /usr/lib/python2.7/netrc.pyR      s    			c         C   s   d |  j  |  j |  j f S(   Ns   %s (%s, line %s)(   R   R   R   (   R   (    (    s   /usr/lib/python2.7/netrc.pyt   __str__   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   R   (    (    (    s   /usr/lib/python2.7/netrc.pyR   
   s   c           B   s/   e  Z d d  „ Z d „  Z d „  Z d „  Z RS(   c         C   sŠ   | d  k rO y  t j j t j d d ƒ } WqO t k
 rK t d ƒ ‚ qO Xn  i  |  _ i  |  _ t	 | ƒ  } |  j
 | | ƒ Wd  QXd  S(   Nt   HOMEs   .netrcs'   Could not find .netrc: $HOME is not set(   R   t   ost   patht   joint   environt   KeyErrort   IOErrort   hostst   macrost   opent   _parse(   R   t   filet   fp(    (    s   /usr/lib/python2.7/netrc.pyR      s     		c         C   s‹  t  j  | ƒ } | j d 7_ | j j d d ƒ | _ xN| j ƒ  } } | sS Pn| d d k rš t | ƒ d } | j j | d ƒ | j j ƒ  q9 nÆ | d k rµ | j ƒ  } n« | d k rÊ d } n– | d k rG| j ƒ  } g  |  j	 | <d	 | _
 xF | j j ƒ  } | s| d
 k r*d | _
 Pn  |  j	 | j | ƒ qû q9 n t d | | | j ƒ ‚ d }	 d  }
 } i  |  j | <x| j ƒ  } | j d ƒ s³| d d d d h k r| rà|	 |
 | f |  j | <| j | ƒ Pqt d | | t | ƒ f | | j ƒ ‚ q€| d k s#| d k r2| j ƒ  }	 q€| d k rM| j ƒ  }
 q€| d k rh| j ƒ  } q€t d | | | j ƒ ‚ q€q9 d  S(   Ns    !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~t   #t    i    i   t   machinet   defaultt   macdefs    	s   
s    	
s   bad toplevel token %rs&   malformed %s entry %s terminated by %st   logint   usert   accountt   passwords   bad follower token %r(   t   shlext	   wordcharst
   commenterst   replacet	   get_tokent   lent   instreamt   seekt   readlineR   t
   whitespacet   appendR   R   R   R   t
   startswitht
   push_tokent   repr(   R   R   R   t   lexert   toplevelt   ttt   post	   entrynamet   lineR   R!   R"   (    (    s   /usr/lib/python2.7/netrc.pyR   "   sh    			

c         C   s<   | |  j  k r |  j  | Sd |  j  k r4 |  j  d Sd Sd S(   s8   Return a (user, account, password) tuple for given host.R   N(   R   R   (   R   t   host(    (    s   /usr/lib/python2.7/netrc.pyt   authenticators`   s
    c         C   sî   d } x‰ |  j  j ƒ  D]x } |  j  | } | d | d t | d ƒ d } | d rr | d t | d ƒ } n  | d t | d	 ƒ d } q WxU |  j j ƒ  D]D } | d
 | d } x |  j | D] } | | } qÈ W| d } q¢ W| S(   s3   Dump the class data in the format of a .netrc file.R   s   machine s   
	login i    s   
i   s   account s
   	password i   s   macdef (   R   t   keysR0   R   (   R   t   repR7   t   attrst   macroR6   (    (    s   /usr/lib/python2.7/netrc.pyt   __repr__i   s    $
 N(   R	   R
   R   R   R   R8   R=   (    (    (    s   /usr/lib/python2.7/netrc.pyR       s   	>		t   __main__(    (   R   R   R#   t   __all__R   R   R    R	   (    (    (    s   /usr/lib/python2.7/netrc.pyt   <module>   s   c