U AT^Tc@sddddgZdZdZdZdZzdd lmZmZWnek rLd Zd ZYnXd d Z d dZ dddZ dddZ dddZ dddZddZddZddZedkred S)encodedecode encodestring decodestrings=iLs0123456789ABCDEF)a2b_qpb2a_qpNcCs:|dkr |S|dkr|S|tkp8d|ko2dkn S)N _ s~)ESCAPE)c quotetabsheaderr/usr/lib64/python3.8/quopri.py needsquotings rcCs(t|}ttt|dt|dfS)N)ordr bytesHEXr rrrquote$srFc Cs2tdk r,|}t|||d}||dS|dfdd}d}|}|sNqg} d} |dddkrv|dd}d} |D]D} t| f} t| ||rt| } |r| dkr| dqz| | qz|dk r||t | } t | t kr|| dt d d d | t d d} q| }q>|dk r.||| d dS) Nr r cSsj|r<|dddkr<||ddt|dd|n*|dkrX|t||n|||dS)Nrs.)writer)soutputlineEndrrrr;s (zencode..writerrr r s= )r) rreadrreadlinerrrZappend EMPTYSTRINGZjoinlen MAXLINESIZE) inputrr rdataodatarZprevlinelineZoutlineZstrippedr Zthislinerrrr,s>           cCsFtdk rt|||dSddlm}||}|}t|||||S)NrrBytesIO)rior*rgetvalue)rr rr*infpoutfprrrrjs c Cstdk r*|}t||d}||dSd}|}|s>qdt|}}|dkr||d|dkrd} |d}|dkr||d|dkr|d}qtnd} ||kr|||d} | dkr|r|d}|d}q| tkr|| }|d}q|d|kr| sd} qq|d|krJ||d|d tkrJ|t}|d }q|d |krt||d|d rt||d |d r|tt||d|d f}|d }q|| }|d}q| s.||dd}q.|r||dS) Nrrrrrs r r i) rr rr!r#r ishexrunhex) r%rrr&r'Znewr(iZnZpartialr rrrrusP       ( B"  cCsDtdk rt||dSddlm}||}|}t|||d|S)Nr/rr))rr+r*rr,)rrr*r-r.rrrrs  cCsHd|kodknpFd|ko*dknpFd|koBdkSS)N09afAFrrrrrr1sr1cCsd}|D]}t|f}d|kr*dkr8nn td}nLd|krLdkr^nntdd}n&d |krrd krnntd d}n|d t||}q|S) Nrr4r5Z0r6r7ai r8r9r)rr)rZbitsr r3rrrr2s  r2c Csddl}ddl}z||jddd\}}WnV|jk r}z6|j|_t|tdtdtd|dW5d}~XYnXd}d}|D] \}}|dkrd}|d krd}q|r|r|j|_td |d|sd g}d} |D]} | d kr|jj } nTzt | d } WnDt k rP}z$|j d | |fd} WYqW5d}~XYnXz*|rjt| |jj nt| |jj |W5| d kr| Xq| r|| dS)NrrZtdz"usage: quopri [-t | -d] [file] ...z-t: quote tabsz-d: decode; default encoder0z-tz-dz -t and -d are mutually exclusivez-Zrbz%s: can't open (%s) )sysgetoptZargvZerrorZstderrZstdoutZprintZexitZstdinZbufferZopenZOSErrorrZcloserr) r;r<ZoptsZargsZmsgZdecoZtabsZor:ZstsZfileZfprrrmainsT     r=Z__main__F)FFr>r>)Z__all__r r$rr"ZbinasciirrZ ImportErrorrrrrrrr1r2r=Z__name__rrrrZs(   > + .