Ñò §ÚêLc @ sÕ d Z d d k Z d d k Z d d k l Z l Z l Z l Z d d d g Z h Z d Z d d „ Z d „ Z d „ Z d d d „ ƒ YZ d d „ Z e e d „ Z d „ Z d „ Z e d j o e ƒ n d S( sž Utilities for comparing files and directories. Classes: dircmp Functions: cmp(f1, f2, shallow=1) -> int cmpfiles(a, b, common) -> ([], [], []) iÿÿÿÿN( t ifiltert ifilterfalset imapt izipt cmpt dircmpt cmpfilesi i i c C sò t t i | ƒ ƒ } t t i | ƒ ƒ } | d t i j p | d t i j o t S| o | | j o t S| d | d j o t St i | | f ƒ } | o | | f | d j o | d St | | ƒ } | | | f t | | f <| S( s” Compare 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. i i i ( t _sigt ost statt S_IFREGt Falset Truet _cachet gett _do_cmp( t f1t f2t shallowt s1t s2t resultt outcome( ( s /usr/lib64/python2.6/filecmp.pyR s ( c C s t i | i ƒ | i | i f S( N( R t S_IFMTt st_modet st_sizet st_mtime( t st( ( s /usr/lib64/python2.6/filecmp.pyR : s c C ss t } t | d ƒ } t | d ƒ } xH t o@ | i | ƒ } | i | ƒ } | | j o t S| p t Sq' Wd S( Nt rb( t BUFSIZEt openR t readR ( R R t bufsizet fp1t fp2t b1t b2( ( s /usr/lib64/python2.6/filecmp.pyR ? s c B sÈ e Z d Z d d d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z e d e d e d e d e d e d e d e d e d e d e d e d e ƒ Z d „ Z RS( sQ A 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. c C sq | | _ | | _ | d j o t i t i g | _ n | | _ | d j o d d d g | _ n | | _ d S( Nt RCSt CVSt tags( t leftt rightt NoneR t curdirt pardirt hidet ignore( t selft at bR. R- ( ( s /usr/lib64/python2.6/filecmp.pyt __init__o s c C sn t t i | i ƒ | i | i ƒ | _ t t i | i ƒ | i | i ƒ | _ | i i ƒ | i i ƒ d S( N( t _filterR t listdirR( R- R. t left_listR) t right_listt sort( R/ ( ( s /usr/lib64/python2.6/filecmp.pyt phase0{ s c C s» t t t t i i | i ƒ | i ƒ ƒ } t t t t i i | i ƒ | i ƒ ƒ } t | i t | i | ƒ ƒ | _ t | i t | i | ƒ ƒ | _ t | i t | i | ƒ ƒ | _ d S( N( t dictR R R t patht normcaseR5 R6 t mapt __getitem__R t __contains__t commonR t left_onlyt right_only( R/ R0 R1 ( ( s /usr/lib64/python2.6/filecmp.pyt phase1ƒ s **!!c C s‰ g | _ g | _ g | _ xg| i D]\} t i i | i | ƒ } t i i | i | ƒ } d } y t i | ƒ } Wn t i j o } d } n Xy t i | ƒ } Wn t i j o } d } n X| o¡ t i | i ƒ } t i | i ƒ } | | j o | i i | ƒ qt i | ƒ o | i i | ƒ qt i | ƒ o | i i | ƒ q| i i | ƒ q% | i i | ƒ q% Wd S( Ni i ( t common_dirst common_filest common_funnyR? R R: t joinR( R) R t errorR R t appendt S_ISDIRt S_ISREG( R/ t xt a_patht b_patht okt a_statt whyt b_statt a_typet b_type( ( s /usr/lib64/python2.6/filecmp.pyt phase2Š s6 c C s7 t | i | i | i ƒ } | \ | _ | _ | _ d S( N( R R( R) RD t same_filest diff_filest funny_files( R/ t xx( ( s /usr/lib64/python2.6/filecmp.pyt phase3 s c C ss h | _ xc | i D]X } t i i | i | ƒ } t i i | i | ƒ } t | | | i | i ƒ | i |