Qf dZddlZddlZddgZGddeZGddZGddZed k(re eyy) z-An object-oriented interface to .netrc files.NnetrcNetrcParseErrorceZdZdZddZdZy)rz5Exception raised on syntax errors in the .netrc file.NcZ||_||_||_tj ||yN)filenamelinenomsg Exception__init__)selfr rr s ,/opt/alt/python312/lib64/python3.12/netrc.pyr zNetrcParseError.__init__ s'   4%cT|jd|jd|jdS)Nz (z, line ))r rr )r s r__str__zNetrcParseError.__str__s%)XXt}}dkkJJr)NN)__name__ __module__ __qualname____doc__r rrrrr s?& Krc$eZdZdZdZdZdZy) _netrclexc<d|_||_d|_g|_y)Nz )r instream whitespacepushback)r fps rr z_netrclex.__init__s  # rcp|jjd}|dk(r|xjdz c_|S)Nr )rreadr )r chs r _read_charz_netrclex._read_chars0 ]]   " : KK1 K rc|jr|jjdSd}t|jd}|D]}||jvr|dk(r-|D]'}|dk(r|ccS|dk(r|j}||z })D|dk(r|j}||z }|D]0}||jvr|ccS|dk(r|j}||z }2|S)Nr"\)rpopiterr$r)r tokenfiterr#s r get_tokenz_netrclex.get_token#s ====$$Q' 'T__b)BT__$SyBSy$ t!__.RKE  :*B BT__,$ t!__.RKE  ( rc:|jj|yr)rappend)r r+s r push_tokenz_netrclex.push_token>s U#rN)rrrr r$r-r0rrrrrs  6$rrc,eZdZddZdZdZdZdZy)rNc|du}|=tjjtjjdd}i|_i|_ t |d5}|j|||dddy#1swYyxYw#t$r9t |d5}|j|||dddYy#1swYYyxYwwxYw)N~z.netrczutf-8)encodinglocale) ospathjoin expanduserhostsmacrosopen_parseUnicodeDecodeError)r file default_netrcrs rr znetrc.__init__Cs <77<< 2 23 7BD   5dW- D"m4.--! 5dX." D"m4/.. 5sH B A=4B =BB B C B=3C =C C C ct|} |j}|jx}}|sy|ddk(r8|j|k(r(t|dk(r|jj b|dk(r|j}n|dk(rd}n|dk(ry|j}g|j |< |jj } | std||j| dk(rn|j |j| Xtd |z||j|std |z||jd x} x} } i|j|< |j} |j}|jdr*|j| k(r|jj X|d vr$| | | f|j|<|j|nb|d k(s|dk(r|j} nF|dk(r|j} n0|dk(r|j} ntd|z||j|j|||j|dO)Nrr#machinedefaultmacdefz.Macro definition missing null line terminator.r!zbad toplevel token %rzmissing %r namer&>r&rErDrCloginuseraccountpasswordzbad follower token %r) rr r-lenrreadliner;rr/r: startswithr0_security_check)r r?rr@lexer saved_linenotopleveltt entrynamelinerFrHrI prev_linenos rr=z netrc._parsePs["  <>224D-L %,,00t|KK *11$7%+b0$ FF%&7"&>%(  ]DJJy4I!4L Myrcxtjdk(r|r|dk7rtj|j}|jtj k7r\ddl} |j|jd} |jtj d}td|d|d|jtjtjzzr tdyyyy#t$rd|jz}YwxYw#t$rdtj z}YwxYw) Nposix anonymousrzuid %sz~/.netrc file owner (z, z) does not match current userzY~/.netrc access too permissive: access permissions must restrict access to only the owner)r6namefstatfilenost_uidgetuidpwdgetpwuidKeyErrorrst_modestatS_IRWXGS_IRWXO)r rr@rFpropr]fownerrGs rrMznetrc._security_checks 77g -E[4H88BIIK(D{{biik)4 \\$++6q9F2<< 4Q7D&,VHBtf=%%''  t|| ;<%!""=5I-   4% 3F4 2#biik1D2s$$C8&D8DD D98D9cx||jvr|j|Sd|jvr|jdSy)z8Return a (user, account, password) tuple for given host.rDN)r:)r hosts rauthenticatorsznetrc.authenticatorss; 4:: ::d# # $** $::i( (rcJd}|jjD]=}|j|}|d|d|ddz }|dr |d|ddz }|d|d dz }?|jjD])}|d |dz }|j|D]}||z } |dz }+|S) z3Dump the class data in the format of a .netrc file.r&zmachine z login rr!rz account z password zmacdef )r:keysr;)r reprgattrsmacrorSs r__repr__znetrc.__repr__sJJOO%DJJt$E XdV:eAhZr: :CQxE!H:R00 [q "- -C & [[%%'E WUG2& &C E*t + 4KC (  rr)rrrr r=rMrhrorrrrrBs 5>N@",r__main__) rr6ra__all__r rrrrprintrrrrssV3 % & Ki K)$)$X{{z z %'Nr