o ?Ogsã@s\dZddlZddlZddlZddgZGdd„deƒZGdd„dƒZedkr,e eƒƒdSdS)z-An object-oriented interface to .netrc files.éNÚnetrcÚNetrcParseErrorc@s"eZdZdZddd„Zdd„ZdS)rz5Exception raised on syntax errors in the .netrc file.NcCs"||_||_||_t ||¡dS©N)ÚfilenameÚlinenoÚmsgÚ ExceptionÚ__init__)Úselfrrr©r ú,/opt/alt/python310/lib64/python3.10/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__Ú__doc__r r r r r r r s  c@s.eZdZd dd„Zdd„Zdd„Zdd „ZdS) rNc CsÊ|du}|durtj tj d¡d¡}i|_i|_z"t|dd}| |||¡WdƒWdS1s4wYWdStydt|dd}| |||¡WdƒYdS1s\wYYdSw)Nú~z.netrczutf-8)ÚencodingÚlocale) ÚosÚpathÚjoinÚ expanduserÚhostsÚmacrosÚopenÚ_parseÚUnicodeDecodeError)r ÚfileÚ default_netrcÚfpr r r r s&ÿ &ÿÿznetrc.__init__cCs˜t |¡}|jd7_|j dd¡|_ |j}| ¡}}|s"dS|ddkr9|j|kr8t|ƒdkr8|j ¡q|dkrB| ¡}n:|dkrId}n3|dkrs| ¡}g|j |<d |_ |j ¡} | re| d krid |_ n |j |  | ¡qZqt d |||jƒ‚d} d} } i|j |< | ¡}| d¡s•|d vr³| r¥| | | f|j |<| |¡n¦t d||t|ƒf||jƒ‚|dks»|dkrÀ| ¡} nŠ|dkrÉ| ¡} n|dkrAtjdkr<|r?@[\]^_`{|}~ú#ÚérÚmachineÚdefaultÚmacdefz Ú z zbad toplevel token %r>r"r$r&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ÚreadlinerZ whitespaceÚappendrrÚ startswithZ push_tokenÚreprrÚnameÚfstatÚfilenoÚst_uidÚgetuidÚpwdÚgetpwuidÚKeyErrorÚst_modeÚstatÚS_IRWXGÚS_IRWXO)r rr rZlexerZ saved_linenoZtoplevelZttZ entrynameÚliner(r*r+Zpropr9Zfownerr)r r r r$s¨        û ÿ    ÿý   ÿÿÿýý ÿ×ßz netrc._parsecCs,||jvr |j|Sd|jvr|jdSdS)z8Return a (user, account, password) tuple for given host.r%N)r)r Úhostr r r Úauthenticatorsus    znetrc.authenticatorscCs¬d}|j ¡D],}|j|}|d|›d|d›d7}|dr)|d|d›d7}|d|d ›d7}q|j ¡D]}|d |›d7}|j|D]}||7}qH|d7}q9|S) z3Dump the class data in the format of a .netrc file.r"zmachine z login rr'r#z account z password ézmacdef )rÚkeysr)r ZreprAZattrsZmacror@r r r Ú__repr__~s   znetrc.__repr__r)rrrr rrBrEr r r r rs   Q Ú__main__) rrr-r=Ú__all__rrrrÚprintr r r r Ús xÿ