3 \k@s`ddlZddlZddlZdddgZGdddeZd ddZd ddZd d Ze d kr\edS)NErrorencodedecodec@s eZdZdS)rN)__name__ __module__ __qualname__rr/usr/lib64/python3.6/uu.pyr'scCsBg}z|dkrtjj}n`t|trz|dkr8tjj|}|dkrfytj|j }Wnt k rdYnXt |d}|j ||dkrtj j}nt|trt |d}|j ||dkrd}|dkrd}|jd|d@|fjd|jd}x,t|d kr|jtj||jd}qW|jd Wdx|D]}|jq*WXdS) N-rbwbiz begin %o %s iascii-rs end )sysstdinbuffer isinstancestrospathbasenamestatst_modeAttributeErroropenappendstdoutwriterreadlenbinasciiZb2a_uuclose)in_fileout_filenamemode opened_filesdatafrrr r*s>           Fc Cs:g}|dkrtjj}nt|tr4t|d}|j|zxr|j}|sNtd|j dsZq:|j dd}t |dkr:|ddkr:yt |d d PWq:t k rYq:Xq:W|dkr|djd jd }tjj|rtd ||dkrt |d d }|dkr tjj}nNt|trXt|d}ytjj||Wntk rHYnX|}|j||j}x|r|jd dkrytj|} Wnjtjk r} zJ|ddd@ddd} tj|d| } |stjjd| WYdd} ~ XnX|j| |j}qbW|stdWdx|D]} | jq"WXdS)Nr r z'No valid begin line found in input filesbegin rs r z"Cannot overwrite existing file: %sr send ?z Warning: %s zTruncated input file)rrrrrrrreadliner startswithsplitrint ValueErrorrstriprrrexistsrchmodrstripr Za2b_uustderrrr!) r"r#r%quietr&ZhdrZ hdrfieldsfpsr'vnbytesr(rrr rZsf              "   cCs4ddl}|jdd}|jdddddd d |jd d d ddd d |j\}}t|dkrl|jdtjdtjj }tj j }t|dkr|d}t|dkr|d}|j r|j rt |trt|d}nttjddtjdt ||nD|j r&t |tr t|d}nttjddtjdt||dS)Nrz'usage: %prog [-d] [-t] [input [output]])Zusagez-dz--decoderzDecode (instead of encode)?F store_true)desthelpdefaultactionz-tz--texttextz2data is text, encoded format unix-compatible text?r*zincorrect number of argumentsr,r z: cannot do -t to stdoutr z: cannot do -t from stdin)optparseZ OptionParserZ add_option parse_argsrerrorrexitrrrrrFrrrprintargvr)rGparserZoptionsargsinputoutputrrr tests6              rQ__main__)NN)NNF) r rr__all__ ExceptionrrrrQrrrrr !s  0 F&