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_qpNcxt|tsJ|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.  _ ~) isinstancebytesESCAPE)c quotetabsheaders -/opt/alt/python312/lib64/python3.12/quopri.py needsquotingrsI a  F{Dy ; 1tq0D011rct|trt|dk(sJt|}ttt |dzt |dzfzS)zQuote a single character.)rrlenordrHEXrs rquoter $sJ a CFAI- - 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%rrrs= )r*) r readr'readlinerrr append EMPTYSTRINGjoinr 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)Nr"r 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 rr#s rr) r r+r'r,rrishexrunhex) r1r)rr2r3newr5inpartialrs 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)NrAr r:)r r<r;rr=)r(rr;r>r?s rrrsA a'' 1:D IE 4v& >> rct|tsJd|cxkxrdkncxs"d|cxkxrdkncxsd|cxkxrdkScS)zDReturn true if the byte ordinal 'c' is a hexadecimal digit in ASCII.09afAF)rrrs rrDrDsF a   1   F 1T 1 FTQ5F$5FF5FFrc&d}|D]}t|f}d|cxkrdkrnn td}nMd|cxkrdkrnntddz }n0d |cxkrd krnntd dz }nJd t|z|d zt||z z}|S) z.Get the integer value of a hexadecimal number.r rLrM0rNrOa rPrQznon-hex digit r)rrrepr)r(bitsrrGs rrErEs D  1$K 1  CA Q $ C A Q $ D " A 2*472 25Bw#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 rtdz"usage: quopri [-t | -d] [file] ...z-t: quote tabsz-d: decode; default encoderBFz-tTz-dz -t and -d are mutually exclusive-rbz: can't open (z) )sysgetoptargverrorstderrstdoutprintexitstdinbufferopenOSErrorr'rrclose) r\r]optsargsmsgdecotabsorTstsfilefps rmainrrs]]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__rr0rr.binasciir r ImportErrorrr rrrrrDrErr__name__rrrzsO ?   ' 239*v'RG $*\ zFy F FsA AA