AlkantarClanX12
Current Path : /proc/thread-self/root/lib64/python2.7/ |
Current File : //proc/thread-self/root/lib64/python2.7/filecmp.pyc |
� zfc @ s� d Z d d l Z d d l Z d d l m Z m Z m Z m Z d d d g Z i 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 k r� 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 j | � � } t t j | � � } | d t j k sP | d t j k rT t S| rj | | k rj t S| d | d k r� t St j | | | | f � } | d k r� t | | � } t t � d k r� t j � n | t | | | | f <n | 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 id N( t _sigt ost statt S_IFREGt Falset Truet _cachet gett Nonet _do_cmpt lent clear( t f1t f2t shallowt s1t s2t outcome( ( s /usr/lib64/python2.7/filecmp.pyR s & c C s t j | j � | j | j f S( N( R t S_IFMTt st_modet st_sizet st_mtime( t st( ( s /usr/lib64/python2.7/filecmp.pyR ; s c C s t } t | d � �d } t | d � �L } xB t rn | j | � } | j | � } | | k ra t S| s- t Sq- WWd QXWd QXd S( Nt rb( t BUFSIZEt openR t readR ( R R t bufsizet fp1t fp2t b1t b2( ( s /usr/lib64/python2.7/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 sm | | _ | | _ | d k r6 t j t j g | _ n | | _ | d k r` d d d g | _ n | | _ d S( Nt RCSt CVSt tags( t leftt rightR R t curdirt pardirt hidet ignore( t selft at bR/ R. ( ( s /usr/lib64/python2.7/filecmp.pyt __init__o s c C sn t t j | j � | j | j � | _ t t j | j � | j | j � | _ | j j � | j j � d S( N( t _filterR t listdirR* R. R/ t left_listR+ t right_listt sort( R0 ( ( s /usr/lib64/python2.7/filecmp.pyt phase0{ s c C s� t t t t j j | j � | j � � } t t t t j j | j � | j � � } t | j t | j | � � | _ t | j t | j | � � | _ t | j t | j | � � | _ d S( N( t dictR R R t patht normcaseR6 R7 t mapt __getitem__R t __contains__t commonR t left_onlyt right_only( R0 R1 R2 ( ( s /usr/lib64/python2.7/filecmp.pyt phase1� s **!!c C s} g | _ g | _ g | _ x[| j D]P} t j j | j | � } t j j | j | � } d } y t j | � } Wn t j k r� } d } n Xy t j | � } Wn t j k r� } d } n X| ret j | j � } t j | j � } | | k r| j j | � qut j | � r0| j j | � qut j | � rR| j j | � qu| j j | � q% | j j | � 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( R0 t xt a_patht b_patht okt a_statt whyt b_statt a_typet b_type( ( s /usr/lib64/python2.7/filecmp.pyt phase2� s4 c C s7 t | j | j | j � } | \ | _ | _ | _ d S( N( R R* R+ RE t same_filest diff_filest funny_files( R0 t xx( ( s /usr/lib64/python2.7/filecmp.pyt phase3� s c C ss i | _ xc | j D]X } t j j | j | � } t j j | j | � } t | | | j | j � | j | <q Wd S( N( t subdirsRD R R; RG R* R+ R R/ R. ( R0 RL t a_xt b_x( ( s /usr/lib64/python2.7/filecmp.pyt phase4� s c C s2 | j � x! | j j � D] } | j � q Wd S( N( R^ R[ t itervaluest phase4_closure( R0 t sd( ( s /usr/lib64/python2.7/filecmp.pyR` � s c C s0 d G| j G| j GH| j rC | j j � d G| j Gd G| j GHn | j rs | j j � d G| j Gd G| j GHn | j r� | j j � d G| j GHn | j r� | j j � d G| j GHn | j r� | j j � d G| j GHn | j r| j j � d G| j GHn | j r,| j j � d G| j GHn d S( Nt diffs Only int :s Identical files :s Differing files :s Trouble with common files :s Common subdirectories :s Common funny cases :( R* R+ RA R8 RB RV RW RX RD RF ( R0 ( ( s /usr/lib64/python2.7/filecmp.pyt report� s, c C s3 | j � x"