nfc@sdZddlZddlZddlZdddgZdefdYZdddZdddd Z d Z e d kre ndS( sImplementation of the UUencode and UUdecode functions. encode(in_file, out_file [,name, mode]) decode(in_file [, out_file, mode]) iNtErrortencodetdecodecBseZRS((t__name__t __module__(((s/usr/lib64/python2.7/uu.pyR'scCsg}z|dkr!tj}nt|tr|d krQtjj|}n|d krytj|j }Wqt k rqXnt |d}|j |n|dkrtj }n.t|trt |d}|j |n|d krd}n|d krd}n|jd|d@|f|jd}x;t|dkr|jtj||jd}qFW|jd Wd x|D]}|jqWXd S( s Uuencode filet-trbtwbis begin %o %s ii-is end N(tsyststdint isinstancet basestringtNonetostpathtbasenametstattst_modetAttributeErrortopentappendtstdouttwritetreadtlentbinasciitb2a_uutclose(tin_filetout_filetnametmodet opened_filestdatatf((s/usr/lib64/python2.7/uu.pyR*s>            ic Csg}|dkrtj}n+t|trIt|}|j|nz^xtr|j}|svtdn|j dsqOn|j dd}t |dkrO|ddkrOyt |dd PWqt k rqXqOqOW|dkr4|dj}tjj|r4td |q4n|dkrVt |dd }n|dkrntj}n_t|trt|d }ytjj||Wntk rnX|}|j|n|j}x|r|jd krytj|} Wnjtjk rs} t|dd d@ddd} tj|| } |sttjjd| qtnX|j| |j}qW|stdnWdx|D]} | jqWXdS(sDecode uuencoded fileRs'No valid begin line found in input filetbegint iiiiis"Cannot overwrite existing file: %sRtendi i?iis Warning: %s sTruncated input fileN(RR R R RRtTruetreadlineRt startswithtsplitRtintt ValueErrorR trstripR RtexistsRtchmodRtstripRta2b_uutordtstderrRR( RRRtquietR thdrt hdrfieldstfptsR!tvtnbytesR"((s/usr/lib64/python2.7/uu.pyRZsf     "        $  c Csddl}|jdd}|jddddd d d td d |jddddd dd td d |j\}}t|dkr|jdtjdntj }tj }t|dkr|d}nt|dkr|d}n|j rb|j rRt |tr2t|d}qRtjdGdGHtjdnt ||nW|j rt |trt|d}qtjdGdGHtjdnt||dS(suuencode/uudecode main programiNtusages'usage: %prog [-d] [-t] [input [output]]s-ds--decodetdestRthelpsDecode (instead of encode)?tdefaulttactiont store_trues-ts--textttexts2data is text, encoded format unix-compatible text?isincorrect number of argumentsiitws: cannot do -t to stdouttrs: cannot do -t from stdin(toptparset OptionParsert add_optiontFalset parse_argsRterrorRtexitR RRR@R R RtargvR(RCtparsertoptionstargstinputtoutput((s/usr/lib64/python2.7/uu.pyttests6 ((        t__main__( t__doc__RR Rt__all__t ExceptionRR RRRPR(((s/usr/lib64/python2.7/uu.pyts   0D %