fc@sdZdadadadtZddlZddlZddlZddl Z dZ ej dZ ej dZ ejd ej d Zed kseejd krejeejd ej ndS( s9Python utility to print MD5 checksums of argument files. itrbs? usage: sum5 [-b] [-t] [-l] [-s bufsize] [file ...] -b : read files in binary mode (default) -t : read files in text mode (you almost certainly don't want this!) -l : print last pathname component only -s bufsize: read buffer size (default %d) file ... : files to sum; '-' or no files means stdin iNcGsd}|r7t|dtr7|d|d }}n tj}t|dkrst|dt rs|d}nxt|D]l}t|tr|dkrttjd|p|}qt||p|}qzt ||p|}qzW|S(Niiit-s( t isinstancetfiletsyststdouttlentstrt printsumfptstdintprintsumtsum(tfilestststouttf((s,/usr/lib64/python2.7/Tools/scripts/md5sum.pyR s &   cCsyyt|t}Wn.tk rC}tjjd||fdSXtrYt|}nt|||}|j|S(Ns%s: Can't open: %s i( topentrmodetIOErrorRtstderrtwritetfnfilterRtclose(tfilenameRtfptmsgR ((s,/usr/lib64/python2.7/Tools/scripts/md5sum.pyR +s cCstj}y1x*|jt}|s+Pn|j|qWWn.tk rm}tjjd||fdSX|jd|j |fdS(Ns%s: I/O error: %s is%s %s i( tmd5tnewtreadtbufsizetupdateRRRRt hexdigest(RRRtmtdataR((s,/usr/lib64/python2.7/Tools/scripts/md5sum.pyR7s icCsytj|d\}}Wn;tjk rY}tjjdtjd|tfdSXxt|D]l\}}|dkrtjj a qa|dkrda qa|dkrd a qa|d krat |a qaqaW|sd g}nt||S( Nsblts:s %s: %s %siis-ls-bRs-ttrs-sR(tgetoptterrorRRRtargvtusagetostpathtbasenameRRtintRR (targsRtoptsRtota((s,/usr/lib64/python2.7/Tools/scripts/md5sum.pytmainEs"$       t__main__i(t__doc__RtNoneRRR&RR'R#RR RR RR%R/t__name__texit(((s,/usr/lib64/python2.7/Tools/scripts/md5sum.pyts