QfdZgdZdZdZdZdZ ddlmZmZd Z d Z dd Z dd Z dd ZddZdZdZdZedk(reyy#e $rdZdZY8wxYw)zHConversions to/from quoted-printable transport encoding as per RFC 1521.)encodedecode encodestring decodestring=Ls0123456789ABCDEF)a2b_qpb2a_qpNcT|dvr|S|dk(r|S|tk(xsd|cxkxrdknc S)zDecide 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.  _ ~)ESCAPE)c quotetabsheaders -/opt/alt/python312/lib64/python3.12/quopri.py needsquotingrs9 F{Dy ; 1tq0D011rcht|}ttt|dzt|dzfzS)zQuote a single character.)ordrbytesHEXrs rquoter$s2 AA E3q"u:s1R4y12 22rct0|j}t|||}|j|y|dfd}d}|jx}rg} d} |dddk(r|dd}d} |D]P} t | f} t | ||r t | } |r| dk(r| jd@| j| R|||tj| } t| tkDr3|| dtd z d | td z d} t| tkDr3| }|jx}r| || yy) 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.Nrr c|r.|dddvr'|j|ddt|ddz|zy|dk(r|jt||zy|j||zy)Nr .)writer)soutputlineEnds rr$zencode..write;sf 236! LL3B%"#-/'9 : $Y LLqG+ , LLW %rrr"rrs= )r') r readr$readlinerrrappend EMPTYSTRINGjoinlen MAXLINESIZE) inputr&rrdataodatar$prevlinelineoutlinestrippedrthislines rrr,s\zz|ty@ U&H.." "$ " 9 9DHAqd AAy&1!H!t)t$q!   (O##G,(mk) (>KM*F ; A /H (mk) 9.." "$ "< h)rctt|||Sddlm}||}|}t|||||j S)Nrr BytesIO)r ior:rgetvalue)r%rrr:infpoutfps rrrgsE a9V<< 1:D IE 4 6* >> rc Nt/|j}t||}|j|yd}|jx}rGdt |}}|dkDr7||dz |dk(r,d} |dz }|dkDr"||dz |dvr|dz }|dkDr||dz |dvrnd} ||kr|||dz} | dk(r |r |d z}|dz}n| t k7r || z}|dz}n|dz|k(r| sd} n|dz|kr!||dz|d zt k(r|t z}|d z}na|d z|krOt ||dz|d zr;t ||d z|d zr'|tt||dz|d zfz}|d z}n || z}|dz}||kr| s|j|dzd}|jx}rG|r|j|yy) zRead '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).Nrrr r(r s rr) r r)r$r*r.rishexrunhex) r0r&rr1r2newr4inpartialrs rrrrs zz|tF+ U C.." "$ "#d)1 q5T!A#a[E)GQqSa%D1QK83aCa%D1QK83G!eQqs ADyVDjac!fAg1Q3q1'U1qT!A#ac]f4Fl!A1qU4!AaC=1eD1QqSM6JE5ac!A##7"9::!AAg1Q3q!e LLu %C3.." "$ "4  S rct t||Sddlm}||}|}t||||j S)Nr@r r9)r r;r:rr<)r%rr:r=r>s rrrsA a'' 1:D IE 4v& >> rcjd|cxkxrdkncxs"d|cxkxrdkncxsd|cxkxrdkScS)zDReturn true if the byte ordinal 'c' is a hexadecimal digit in ASCII.09afAFrs rrCrCs8 1   F 1T 1 FTQ5F$5FF5FFrcd}|D]u}t|f}d|cxkrdkrnn td}n9d|cxkrdkrnntddz }nd |cxkrd krnntd dz }|d zt|z z}w|S) z.Get the integer value of a hexadecimal number.r rKrL0rMrNa rOrPr)rr)r%bitsrrFs rrDrDs D  1$K 1  CA Q $ C A Q $ D " ABw#a&1*% Krcddl}ddl} |j|jddd\}}d}d}D]\}}|d k(rd }|d k(sd }|r/|r-|j|_t d |jdsd g}d} |D]} | d k(r|jj} n t| d} |r!t| |j jn!t| |j j|| d k7sw| j| r|j| yy#|j$rY}|j|_t |t dt dt d|jdYd}~Xd}~wwxYw#t$r.}|jj| d|dd} Yd}~;d}~wwxYw#| d k7r| jwwxYw)Nr r(tdz"usage: quopri [-t | -d] [file] ...z-t: quote tabsz-d: decode; default encoderAFz-tTz-dz -t and -d are mutually exclusive-rbz: can't open (z) )sysgetoptargverrorstderrstdoutprintexitstdinbufferopenOSErrorr$rrclose) r[r\optsargsmsgdecotabsorTstsfilefps rmainrqs]]388AB<6 d D D1 9Td 9Td ZZ  01   C 3;!!B $%  r3::,,-r3::,,d3s{ #$    I <<ZZ  c  23  *+  0    D#!FG s{ s="D!# F 0AG!F 0AFF  G#F>>GG__main__)F)FF)__doc____all__rr/rr,binasciir r ImportErrorrrrrrrrCrDrq__name__rQrrrxsO ?   ' 239*v'RG $*\ zFy F FsA AA