ó n”þfc@sädZddddgZdZdZdZdZyd d lmZmZWne k ridZdZnXd „Z d „Z d d„Z d d d„Zd d„Zd d„Zd„Zd„Zd„ZedkràeƒndS(sHConversions to/from quoted-printable transport encoding as per RFC 1521.tencodetdecodet encodestringt decodestringt=iLt0123456789ABCDEFtiÿÿÿÿ(ta2b_qptb2a_qpcCsG|dkr|S|dkr |S|tkpFd|koCdkn 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/usr/lib64/python2.7/quopri.pyt needsquotings   cCs(t|ƒ}tt|dt|dS(sQuote a single character.i(tordR tHEX(R ti((s/usr/lib64/python2.7/quopri.pytquote#s ic Cs’tdk rA|jƒ}t|d|d|ƒ}|j|ƒdS|dd„}d}x|jƒ}|soPng} d} |ddkrž|d }d} nx^|D]V} t| ||ƒrÌt| ƒ} n|rî| dkrî| jd ƒq¥| j| ƒq¥W|dk r||ƒntj | ƒ} x<t | ƒt kre|| t d  d d ƒ| t d } q*W| }qY|dk rŽ||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 cSsw|r<|ddkr<|j|d t|dƒ|ƒn7|dkrb|jt|ƒ|ƒn|j||ƒdS(Niÿÿÿÿs t.(twriteR(tstoutputtlineEnd((s/usr/lib64/python2.7/quopri.pyR;s & RiÿÿÿÿR R iRs= ( RtNonetreadRtreadlineRRtappendt EMPTYSTRINGtjointlent MAXLINESIZE( tinputRRRtdatatodataRtprevlinetlinetoutlinetstrippedR tthisline((s/usr/lib64/python2.7/quopri.pyR*s>            cCsdtdk r"t|d|d|ƒSddlm}||ƒ}|ƒ}t||||ƒ|jƒS(NRRiÿÿÿÿ(tStringIO(RRt cStringIOR*Rtgetvalue(RRRR*tinfptoutfp((s/usr/lib64/python2.7/quopri.pyRis   c CsWtdk r;|jƒ}t|d|ƒ}|j|ƒdSd}xù|jƒ}|sZPndt|ƒ}}|dkrÑ||ddkrÑd} |d}x7|dkrÍ||ddkrÍ|d}q Wnd} x@||kr||} | dkr|r|d }|d}qÚ| tkr<|| }|d}qÚ|d|kr]| r]d} PqÚ|d|kr˜||dtkr˜|t}|d }qÚ|d |krt||dƒrt||d ƒr|tt ||d|d !ƒƒ}|d }qÚ|| }|d}qÚW| sD|j|dƒd}qDqD|rS|j|ƒ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/usr/lib64/python2.7/quopri.pyRtsR      #    $ 8%   cCs^tdk rt|d|ƒSddlm}||ƒ}|ƒ}t||d|ƒ|jƒS(NRiÿÿÿÿ(R*(RRR+R*RR,(RRR*R-R.((s/usr/lib64/python2.7/quopri.pyRŸs   cCsPd|kodknpOd|ko3dknpOd|koMdkSS(s8Return true if the character 'c' is a hexadecimal digit.t0t9tatftAtF((R ((s/usr/lib64/python2.7/quopri.pyR/«scCs½d}x°|D]¨}d|ko*dknr>tdƒ}n_d|koUdknrmtdƒd}n0d|ko„dknrœtdƒd}nP|d t|ƒ|}q W|S( s.Get the integer value of a hexadecimal number.iR5R6R7R8i R9R:i(R(RtbitsR R((s/usr/lib64/python2.7/quopri.pyR1¯s c Csçddl}ddl}y#|j|jddƒ\}}WnC|jk r€}|j|_|GHdGHdGHdGH|jdƒnXd}d}x>|D]6\}}|d krµd}n|d kr”d}q”q”W|rû|rû|j|_d GH|jdƒn|s d g}nd} x·|D]¯} | d kr8|j} nIyt| ƒ} Wn6t k r€}|jj d | |fƒd} qnX|ršt | |jƒnt | |j|ƒ| |jk r| j ƒqqW| rã|j| ƒ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/usr/lib64/python2.7/quopri.pytmainÀsR  #         t__main__N(t__doc__t__all__R R!RRtbinasciiRRt ImportErrorRRRRRRRR/R1RRt__name__(((s/usr/lib64/python2.7/quopri.pyts*     ? +   ,