grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î ¤ faã @sdZddddgZdZdZdZdZyd d lmZmZWne k rjd Zd ZYnXd d „Z dd„Z ddd„Z dddd„Z ddd„Zddd„Zdd„Zdd„Zdd„Zedkrüeƒnd S)zHConversions to/from quoted-printable transport encoding as per RFC 1521.ÚencodeÚdecodeÚ encodestringÚ decodestringó=éLs0123456789ABCDEFóé)Úa2b_qpÚb2a_qpNcCs\t|tƒst‚|dkr%|S|dkr5|S|tkp[d|koXdkn S)zìDecide whether a particular byte ordinal 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 ó_ó ó~)Ú isinstanceÚbytesÚAssertionErrorÚESCAPE)ÚcÚ quotetabsÚheader©rú+/opt/alt/python34/lib64/python3.4/quopri.pyÚ needsquotings   rcCsWt|tƒr!t|ƒdks't‚t|ƒ}ttt|dt|dfƒS)zQuote a single character.éé)rrÚlenrÚordrÚHEX)rrrrÚquote$s' rFc Cs½tdk rA|jƒ}t|d|d|ƒ}|j|ƒdS|ddd„}d}x>|jƒ}|srPng} d} |d d…dkr­|dd…}d} nxm|D]e} t| fƒ} t| ||ƒrêt| ƒ} n|r | d kr | jd ƒq´| j| ƒq´W|dk r6||ƒntj | ƒ} xHt | ƒt kr�|| dt d…d d ƒ| t dd…} qHW| }q\W|dk r¹||d | ƒndS)avRead 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are binary file objects. 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.Nrrs cSs‰|rN|dd…dkrN|j|dd…t|dd…ƒ|ƒn7|dkrt|jt|ƒ|ƒn|j||ƒdS)Nrs ó.éÿÿÿÿrr)Úwriter)ÚsÚoutputÚlineEndrrrr ;s 2 zencode..writerrr r r#s= rr) r Úreadr ÚreadlinerrrÚappendÚ EMPTYSTRINGÚjoinrÚ MAXLINESIZE) Úinputr"rrÚdataÚodatar ZprevlineÚlineZoutlineZstrippedrZthislinerrrr,s@           cCsdtdk r"t|d|d|ƒSddlm}||ƒ}|ƒ}t||||ƒ|jƒS)Nrrr)ÚBytesIO)r Úior.rÚgetvalue)r!rrr.ÚinfpÚoutfprrrrjs   c Cs’tdk r;|jƒ}t|d|ƒ}|j|ƒdSd}x4|jƒ}|sZPndt|ƒ}}|dkrÝ||d|…dkrÝd} |d}x=|dkrÙ||d|…dkrÙ|d}q¦Wnd} xn||krS|||d…} | dkr/|r/|d }|d}qæ| tkrR|| }|d}qæ|d|krs| rsd} Pqæ|d|kr¸||d|d …tkr¸|t}|d }qæ|d |kr<t||d|d …ƒr<t||d |d …ƒr<|tt||d|d …ƒfƒ}|d }qæ|| }|d}qæW| sD|j|dƒd}qDqDW|rŽ|j|ƒndS) z»Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are binary file objects. If 'header' is true, decode underscore as space (per RFC 1522).Nrrrrs s r r éé) r r$r r%rrÚishexrÚunhex) r*r"rr+r,Únewr-ÚiÚnÚpartialrrrrrusR    & )   . L+   cCs^tdk rt|d|ƒSddlm}||ƒ}|ƒ}t||d|ƒ|jƒS)Nrr)r.)r r/r.rr0)r!rr.r1r2rrrr s   cCset|tƒst‚d|ko,dknpdd|koHdknpdd|kobdkSS)zDReturn true if the byte ordinal 'c' is a hexadecimal digit in ASCII.ó0ó9óaófóAóF)rrr)rrrrr5¬sr5cCsçd}xÚ|D]Ò}t|fƒ}d|ko9dknrMtdƒ}nzd|koddknr|tdƒd}nKd |ko“d knr«td ƒd}nd sÇtd t|ƒƒ‚|d t|ƒ|}q W|S)z.Get the integer value of a hexadecimal number.rr;r<Ú0r=r>Úaé r?r@Fznon-hex digit r)rrrÚrepr)r!Úbitsrr8rrrr6±s r6c (Cs;ddl}ddl}y)|j|jdd…dƒ\}}Wni|jk r¬}zF|j|_t|ƒtdƒtdƒtdƒ|jdƒWYdd}~XnXd}d}x>|D]6\}}|dkrád}n|d krÀd}qÀqÀW|r,|r,|j|_td ƒ|jdƒn|s>d g}nd} xÚ|D]Ò} | d krl|jj } n^yt | d ƒ} WnHt k rÉ}z(|jj d | |fƒd} wKWYdd}~XnXz6|rét | |jj ƒnt| |jj |ƒWd| d kr| jƒnXqKW| r7|j| ƒndS)NrrZtdz"usage: quopri [-t | -d] [file] ...z-t: quote tabsz-d: decode; default encoder3z-tz-dz -t and -d are mutually exclusiveú-Úrbz%s: can't open (%s) )ÚsysÚgetoptÚargvÚerrorÚstderrÚstdoutÚprintÚexitÚstdinÚbufferÚopenÚOSErrorr rrÚclose) rHrIZoptsÚargsÚmsgZdecoZtabsÚorBÚstsÚfileÚfprrrÚmainÃsT  )               r[Ú__main__)Ú__doc__Ú__all__rr)rr'Zbinasciir r Ú ImportErrorrrrrrrr5r6r[Ú__name__rrrrÚs*    > +   .