Ńň §ÚęLc @ sč d Z d d d d g Z d Z d Z d Z d Z y d d k l Z l Z Wn e j o d Z d Z n Xd Z d Z d d Z d d d Z d d Z d d Z d Z d Z d Z e d j o e n d S( sH Conversions to/from quoted-printable transport encoding as per RFC 1521.t encodet decodet encodestringt decodestringt =iL t 0123456789ABCDEFt i˙˙˙˙( t a2b_qpt b2a_qpc C sM | d j o | S| d j o | S| t j p d | j o d j n 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 ~( t ESCAPE( t ct quotetabst header( ( s /usr/lib64/python2.6/quopri.pyt needsquoting s c C s( t | } t t | d t | d S( s Quote a single character.i ( t ordR t HEX( R t i( ( s /usr/lib64/python2.6/quopri.pyt quote# s i c C sŁ t d j o6 | i } t | d | d | } | i | d S| d d } d } x#| i } | p Pn g } d } | d d j o | d } d } n xc | D][ } t | | | o t | } n | o | d j o | i d qŤ | i | qŤ W| d j o | | n t i | } x> t | t j o* | | t d d d | t d } q7W| } q[ | d j o | | d | n d S( 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. R R Ns c S s| | o8 | d d j o' | i | d t | d | n: | d j o | i t | | n | i | | d S( Ni˙˙˙˙s t .( t writeR ( t st outputt lineEnd( ( s /usr/lib64/python2.6/quopri.pyR ; s ' R i˙˙˙˙R R i R s = ( R t Nonet readR t readlineR R t appendt EMPTYSTRINGt joint lent MAXLINESIZE( t inputR R R t datat odataR t prevlinet linet outlinet strippedR t thisline( ( s /usr/lib64/python2.6/quopri.pyR * sB c C sf t d j o t | d | d | Sd d k l } | | } | } t | | | | | i S( NR R i˙˙˙˙( t StringIO( R R t cStringIOR* R t getvalue( R R R R* t infpt outfp( ( s /usr/lib64/python2.6/quopri.pyR i s c C sv t d j o0 | i } t | d | } | i | d Sd } x| i } | p Pn d t | } } | d j o] | | d d j oH d } | d } x; | d j o# | | d d j o | d } qŚ Wn d } xQ| | j oC| | } | d j o | o | d } | d } qä | t j o | | } | d } qä | d | j o | o d } Pqä | d | j o- | | d t j o | t } | d } qä | d | j o] t | | d oH t | | d o3 | t t | | d | d ! } | d } qä | | } | d } qä W| p | i | d d } qF qF | o | i | n d S( 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).R NR i i s s R R i i ( R R R R R R R t ishext chrt unhex( R" R R R# R$ t newR&