zfc@sdZddlZddlZddlZejdkrHddlZnddgZdefdYZdd dYZ e dkre GHndS( s-An object-oriented interface to .netrc files.iNtposixtnetrctNetrcParseErrorcBs&eZdZdddZdZRS(s5Exception raised on syntax errors in the .netrc file.cCs/||_||_||_tj||dS(N(tfilenametlinenotmsgt Exceptiont__init__(tselfRRR((s/usr/lib64/python2.7/netrc.pyRs   cCsd|j|j|jfS(Ns%s (%s, line %s)(RRR(R((s/usr/lib64/python2.7/netrc.pyt__str__sN(t__name__t __module__t__doc__tNoneRR (((s/usr/lib64/python2.7/netrc.pyR scBs/eZddZdZdZdZRS(cCs|dk}|dkr[y tjjtjdd}Wq[tk rWtdq[Xni|_i|_t |}|j |||WdQXdS(NtHOMEs.netrcs'Could not find .netrc: $HOME is not set( R tostpathtjointenvirontKeyErrortIOErrorthoststmacrostopent_parse(Rtfilet default_netrctfp((s/usr/lib64/python2.7/netrc.pyRs      cCstj|}|jd7_|jjdd|_x`|j}}|sSPn|ddkrt|d}|jj| d|jjq9n|dkr|j}n|dkrd}n|dkrH|j}g|j |?@[\]^_`{|}~t#tiitmachinetdefaulttmacdefs s s sbad toplevel token %rs&malformed %s entry %s terminated by %stlogintusertaccounttpasswordRsuid %ss9~/.netrc file owner (%s) does not match current user (%s)sY~/.netrc access too permissive: access permissions must restrict access to only the ownersbad follower token %r( tshlext wordcharst commenterstreplacet get_tokentlentinstreamtseektreadlineRt whitespacetappendRRR Rt startswitht push_tokentreprRtnametfstattfilenotst_uidtgetuidtpwdtgetpwuidRtst_modetstattS_IRWXGtS_IRWXO(RRRRtlexerttoplevelttttpost entrynametlineR!R#R$tproptfownerR"((s/usr/lib64/python2.7/netrc.pyR%s                   cCs<||jkr|j|Sd|jkr4|jdSdSdS(s8Return a (user, account, password) tuple for given host.RN(RR (Rthost((s/usr/lib64/python2.7/netrc.pytauthenticatorsws   cCsd}xy|jjD]h}|j|}|djd|d|7}|drh|djd|7}n|djd|7}qWxY|jjD]H}|djd |7}x|j|D]}||7}qW|d 7}qW|S( s3Dump the class data in the format of a .netrc file.Rs!machine {host} login {attrs[0]} RFtattrsis account {attrs[1]} s password {attrs[2]} smacdef {macro} tmacros (RtkeystformatR(RtrepRFRHRIRC((s/usr/lib64/python2.7/netrc.pyt__repr__s  N(R R R RRRGRM(((s/usr/lib64/python2.7/netrc.pyRs R t__main__(( R RR;R%R3R8t__all__RRRR (((s/usr/lib64/python2.7/netrc.pyts$  x