łň <ŻbCc@sčdZddddgZdZdZdZdZyd d klZlZWne j odZdZnXd „Z d „Z d d„Z d d d„Zd d„Zd d„Zd„Zd„Zd„Zedjo eƒndS(sHConversions to/from quoted-printable transport encoding as per RFC 1521.tencodetdecodet encodestringt decodestringt=iLt0123456789ABCDEFti˙˙˙˙(ta2b_qptb2a_qpcCsS|djo|Sn|djo|Sn|tjpd|jo djn S(séDecide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. s t_t t~(tESCAPE(tct quotetabstheader((s quopri.pyct needsquotings   cCs(t|ƒ}tt|dt|dS(sQuote a single character.i(tordR tHEX(R ti((s quopri.pyctquote#s ic CsŚtdj o9|iƒ}t|d|d|ƒ}|i|ƒdSn|dd„}d}x#|iƒ}|pPng} d} |ddjo|d }d} nxc|D][} t| ||ƒot| ƒ} n|o| djo| id ƒqŽ| i| ƒqŽW|dj o||ƒnti | ƒ} x>t | ƒt jo*|| t d  d d ƒ| t d } q:W| }q^|dj o||d | ƒndS( s–Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. The 'header' flag indicates whether we are encoding spaces as _ as per RFC 1522. RRNs cSs||o8|ddjo'|i|d t|dƒ|ƒn:|djo|it|ƒ|ƒn|i||ƒdS(Ni˙˙˙˙s t.(twriteR(tstoutputtlineEnd((s quopri.pycR;s ' Ri˙˙˙˙R R iRs= ( RtNonetreadRtreadlineRRtappendt EMPTYSTRINGtjointlent MAXLINESIZE( tinputRRRtdatatodataRtprevlinetlinetoutlinetstrippedR tthisline((s quopri.pycR*sB          cCsitdj ot|d|d|ƒSnddkl}||ƒ}|ƒ}t||||ƒ|iƒS(NRRi˙˙˙˙(tStringIO(RRt cStringIOR*Rtgetvalue(RRRR*tinfptoutfp((s quopri.pycRis   c Csytdj o3|iƒ}t|d|ƒ}|i|ƒdSnd}x|iƒ}|pPndt|ƒ}}|djo]||ddjoHd} |d}x;|djo#||ddjo|d}qŠWnd} xQ||joC||} | djo|o|d }|d}qç| tjo|| }|d}qç|d|jo| o d} Pqç|d|jo-||dtjo|t}|d }qç|d |jo]t||dƒoHt||d ƒo3|tt ||d|d !ƒƒ}|d }qç|| }|d}qçW| p|i|dƒd}qIqI|o|i|ƒndS( sŃRead 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. If 'header' is true, decode underscore as space (per RFC 1522).RNRiis s R R ii( RRRRRR R tishextchrtunhex( R"RRR#R$tnewR&RtntpartialR ((s quopri.pycRtsV    " "     & ;%  cCsctdj ot|d|ƒSnddkl}||ƒ}|ƒ}t||d|ƒ|iƒS(NRi˙˙˙˙(R*(RRR+R*RR,(RRR*R-R.((s quopri.pycRŸs   cCsWd|jo djnp9d|jo djnpd|jo djnS(s8Return true if the character 'c' is a hexadecimal digit.t0t9tatftAtF((R ((s quopri.pycR/ŤscCsĆd}xš|D]ą}d|jo djnotdƒ}nfd|jo djnotdƒd}n4d|jo djnotdƒd}nP|d t|ƒ|}q W|S( s.Get the integer value of a hexadecimal number.iR5R6R7R8i R9R:i(R(RtbitsR R((s quopri.pycR1Żsc Csüddk}ddk}y#|i|iddƒ\}}WnE|ij o6}|i|_|GHdGHdGHdGH|idƒnXd}d}xB|D]:\}}|d jo d}n|d jo d}q–q–W|o)|o"|i|_d GH|idƒn|p d g}nd} xż|D]ˇ} | d jo |i} nLyt| ƒ} Wn8t j o,}|ii d | |fƒd} q%nX|ot | |iƒnt | |i|ƒ| |ij o| i ƒq%q%W| o|i| ƒndS(Ni˙˙˙˙ittds"usage: quopri [-t | -d] [file] ...s-t: quote tabss-d: decode; default encodeiis-ts-ds -t and -d are mutually exclusivet-s%s: can't open (%s) (tsystgetopttargvterrortstderrtstdouttexittstdintopentIOErrorRRRtclose( R>R?toptstargstmsgtdecottabstoR7tststfiletfp((s quopri.pyctmainŔsV  #        t__main__N(t__doc__t__all__R R!RRtbinasciiRRt ImportErrorRRRRRRRR/R1RRt__name__(((s quopri.pycss*    ? +   ,