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_qpNcCsG|dkr|S|dkr |S|tkpFd|koCdkn 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 ó_ó ó~)ÚESCAPE)ÚcÚ quotetabsÚheader©rú+/opt/alt/python34/lib64/python3.4/quopri.pyÚ needsquotings   rcCs0t|ƒ}ttt|dt|dfƒS)zQuote a single character.é)ÚordrÚbytesÚ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)Nés ó.éÿÿÿÿrr)Úwriter)ÚsÚoutputÚlineEndrrrr;s 2 zencode..writerrr r r s= rr) r ÚreadrÚreadlinerrrÚappendÚ EMPTYSTRINGÚjoinÚlenÚ MAXLINESIZE) ÚinputrrrÚdataÚodatarZprevlineÚlineZoutlineZstrippedrZthislinerrrr,s@           cCsdtdk r"t|d|d|ƒSddlm}||ƒ}|ƒ}t||||ƒ|jƒS)Nrrr)ÚBytesIO)r Úior,rÚgetvalue)rrrr,Ú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!rr"r&rÚishexrÚunhex) r(rrr)r*Únewr+ÚiÚnÚpartialrrrrrusR    & )   . L+   cCs^tdk rt|d|ƒSddlm}||ƒ}|ƒ}t||d|ƒ|jƒS)Nrr)r,)r r-r,rr.)rrr,r/r0rrrr s   cCsPd|kodknpOd|ko3dknpOd|koMdkSS)zDReturn true if the byte ordinal 'c' is a hexadecimal digit in ASCII.ó0ó9óaófóAóFr)rrrrr3¬sr3cCsËd}x¾|D]¶}t|fƒ}d|ko9dknrMtdƒ}n^d|koddknr|tdƒd}n/d |ko“d knr«td ƒd}n|d t|ƒ|}q W|S) z.Get the integer value of a hexadecimal number.rr9r:Ú0r;r<Úaé r=r>r)rr)rÚbitsrr6rrrr4±s r4c (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 encoder1z-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ÚOSErrorrrrÚclose) rErFZoptsÚargsÚmsgZdecoZtabsÚor@ÚstsÚfileÚfprrrÚmainÃsT  )               rXÚ__main__)Ú__doc__Ú__all__rr'rr$Zbinasciir r Ú ImportErrorrrrrrrr3r4rXÚ__name__rrrrÚs*    > +   .