Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/
Upload File :
Current File : //usr/lib/python2.7/filecmp.pyc


|_c@sdZddlZddlZddlmZmZmZmZdddgZiZ	dZ
d	d
ZdZdZ
ddd
YZd	dZeedZdZdZedkrendS(sUtilities for comparing files and directories.

Classes:
    dircmp

Functions:
    cmp(f1, f2, shallow=1) -> int
    cmpfiles(a, b, common) -> ([], [], [])

iN(tifiltertifilterfalsetimaptiziptcmptdircmptcmpfilesiiicCsttj|}ttj|}|dtjksP|dtjkrTtS|rj||krjtS|d|dkrtStj||||f}|dkrt	||}t
tdkrtjn|t||||f<n|S(sCompare two files.

    Arguments:

    f1 -- First file name

    f2 -- Second file name

    shallow -- Just check stat signature (do not read the files).
               defaults to 1.

    Return value:

    True if the files are the same, False otherwise.

    This function uses a cache for past comparisons and the results,
    with a cache invalidation mechanism relying on stale signatures.

    iiidN(t_sigtoststattS_IFREGtFalsetTruet_cachetgettNonet_do_cmptlentclear(tf1tf2tshallowts1ts2toutcome((s/usr/lib/python2.7/filecmp.pyRs&
cCstj|j|j|jfS(N(R	tS_IFMTtst_modetst_sizetst_mtime(tst((s/usr/lib/python2.7/filecmp.pyR;sc
Cst}t|dd}t|dL}xBtrn|j|}|j|}||kratS|s-tSq-WWdQXWdQXdS(Ntrb(tBUFSIZEtopenRtreadR(RRtbufsizetfp1tfp2tb1tb2((s/usr/lib/python2.7/filecmp.pyR@s	cBseZdZdddZdZdZdZdZdZ	dZ
dZd	Zd
Z
ede	ded
edededededededededeZdZRS(sQA class that manages the comparison of 2 directories.

    dircmp(a,b,ignore=None,hide=None)
      A and B are directories.
      IGNORE is a list of names to ignore,
        defaults to ['RCS', 'CVS', 'tags'].
      HIDE is a list of names to hide,
        defaults to [os.curdir, os.pardir].

    High level usage:
      x = dircmp(dir1, dir2)
      x.report() -> prints a report on the differences between dir1 and dir2
       or
      x.report_partial_closure() -> prints report on differences between dir1
            and dir2, and reports on common immediate subdirectories.
      x.report_full_closure() -> like report_partial_closure,
            but fully recursive.

    Attributes:
     left_list, right_list: The files in dir1 and dir2,
        filtered by hide and ignore.
     common: a list of names in both dir1 and dir2.
     left_only, right_only: names only in dir1, dir2.
     common_dirs: subdirectories in both dir1 and dir2.
     common_files: files in both dir1 and dir2.
     common_funny: names in both dir1 and dir2 where the type differs between
        dir1 and dir2, or the name is not stat-able.
     same_files: list of identical files.
     diff_files: list of filenames which differ.
     funny_files: list of files which could not be compared.
     subdirs: a dictionary of dircmp objects, keyed by names in common_dirs.
     cCsm||_||_|dkr6tjtjg|_n	||_|dkr`dddg|_n	||_dS(NtRCStCVSttags(tlefttrightRRtcurdirtpardirthidetignore(tselftatbR/R.((s/usr/lib/python2.7/filecmp.pyt__init__os			cCsnttj|j|j|j|_ttj|j|j|j|_|jj	|jj	dS(N(
t_filterRtlistdirR*R.R/t	left_listR+t
right_listtsort(R0((s/usr/lib/python2.7/filecmp.pytphase0{s
cCsttttjj|j|j}ttttjj|j|j}t|j	t
|j||_t|j	t
|j||_t|j	t
|j||_dS(N(tdictRRRtpathtnormcaseR6R7tmapt__getitem__Rt__contains__tcommonRt	left_onlyt
right_only(R0R1R2((s/usr/lib/python2.7/filecmp.pytphase1s
**!!c
Cs}g|_g|_g|_x[|jD]P}tjj|j|}tjj|j|}d}ytj	|}Wntj
k
r}d}nXytj	|}Wntj
k
r}d}nX|ret	j|j}t	j|j}	||	kr|jj
|qut	j|r0|jj
|qut	j|rR|jj
|qu|jj
|q%|jj
|q%WdS(Nii(tcommon_dirstcommon_filestcommon_funnyR@RR;tjoinR*R+R	terrorRRtappendtS_ISDIRtS_ISREG(
R0txta_pathtb_pathtokta_stattwhytb_statta_typetb_type((s/usr/lib/python2.7/filecmp.pytphase2s4			

cCs7t|j|j|j}|\|_|_|_dS(N(RR*R+REt
same_filest
diff_filestfunny_files(R0txx((s/usr/lib/python2.7/filecmp.pytphase3scCssi|_xc|jD]X}tjj|j|}tjj|j|}t|||j|j	|j|<qWdS(N(
tsubdirsRDRR;RGR*R+RR/R.(R0RLta_xtb_x((s/usr/lib/python2.7/filecmp.pytphase4s
	cCs2|jx!|jjD]}|jqWdS(N(R^R[t
itervaluestphase4_closure(R0tsd((s/usr/lib/python2.7/filecmp.pyR`s
cCs0dG|jG|jGH|jrC|jjdG|jGdG|jGHn|jrs|jjdG|jGdG|jGHn|jr|jjdG|jGHn|jr|jjdG|jGHn|jr|jjdG|jGHn|jr|jjdG|jGHn|j	r,|j	jdG|j	GHndS(	NtdiffsOnly int:sIdentical files :sDiffering files :sTrouble with common files :sCommon subdirectories :sCommon funny cases :(
R*R+RAR8RBRVRWRXRDRF(R0((s/usr/lib/python2.7/filecmp.pytreports,	
	
	
	
	
	
	
cCs3|jx"|jjD]}H|jqWdS(N(RdR[R_(R0Ra((s/usr/lib/python2.7/filecmp.pytreport_partial_closures
cCs3|jx"|jjD]}H|jqWdS(N(RdR[R_treport_full_closure(R0Ra((s/usr/lib/python2.7/filecmp.pyRfs
R[RVRWRXRDRERFR@RARBR6R7cCs9||jkrt|n|j||t||S(N(t	methodmaptAttributeErrortgetattr(R0tattr((s/usr/lib/python2.7/filecmp.pyt__getattr__sN(t__name__t
__module__t__doc__RR3R9RCRURZR^R`RdReRfR:RgRk(((s/usr/lib/python2.7/filecmp.pyRMs" 			#		
				cCskgggf}xU|D]M}tjj||}tjj||}|t|||j|qW|S(s]Compare common files in two directories.

    a, b -- directory names
    common -- list of file names found in both directories
    shallow -- if true, do comparison based solely on stat() information

    Returns a tuple of three lists:
      files that compare equal
      files that are different
      filenames that aren't regular files.

    (RR;RGt_cmpRI(R1R2R@RtresRLtaxtbx((s/usr/lib/python2.7/filecmp.pyRs

!cCs7y|||||SWntjk
r2dSXdS(Ni(RRH(R1R2tshtabsR((s/usr/lib/python2.7/filecmp.pyRoscCstt|j|S(N(tlistRR?(tflisttskip((s/usr/lib/python2.7/filecmp.pyR4scCsddl}ddl}|j|jdd\}}t|dkr^|jddnt|d|d}d	|kr|jn
|jdS(
Niitrisneed exactly two argsis-rt(s-rRy(	tsystgetopttargvRtGetoptErrorRRRfRd(RzR{toptionstargstdd((s/usr/lib/python2.7/filecmp.pytdemos
t__main__i ((RnRR	t	itertoolsRRRRt__all__R
RRRRRRRtRoR4RRl(((s/usr/lib/python2.7/filecmp.pyt<module>
s "&