-í
è¶<c       sb     d  Z  	  d k Z  d k T d k Z  h  Z  d d „ Z 2 d „  Z 6 d „  Z d S(   s­  Efficiently compare files, boolean outcome only (equal / not equal).

Tricks (used in this order):
    - Use the statcache module to avoid statting files more than once
    - Files with identical type, size & mtime are assumed to be clones
    - Files with different type or size cannot be identical
    - We keep a cache of outcomes of earlier comparisons
    - We don't fork a process to run 'cmp' but read the files ourselves
N(   s   *i   c 	   sI     t  t i |  ƒ ƒ t  t i | ƒ ƒ f \ } }  t | d ƒ p t | d ƒ o  d Sn  | o
 | | j o   d Sn ! | d  | d  j o # d Sn % |  d | } & t
 i | ƒ oB ' t
 | \ } } } ) | | j o
 | | j o + | Sn n . t |  | ƒ } / | | | f t
 | <0 | Sd S(   sß   Compare two files, use the cache if possible.
    May raise os.error if a stat or open of either fails.
    Return 1 for identical files, 0 for different.
    Raise exceptions if either file could not be statted, read, etc.i    i   i   s    N(   s   sigs	   statcaches   stats   f1s   f2s   s1s   s2s   S_ISREGs   shallows   keys   caches   has_keys   cs1s   cs2s   outcomes   do_cmp(	   s   f1s   f2s   shallows   s1s   keys   s2s   outcomes   cs1s   cs2(    (    s&   /usr/lib/python2.2/lib-old/cmpcache.pys   cmp s    3'c    s,   2 3 4 t  |  t ƒ |  t |  t f Sd S(   s>   Return signature (i.e., type, size, mtime) from raw stat data.N(   s   S_IFMTs   sts   ST_MODEs   ST_SIZEs   ST_MTIME(   s   st(    (    s&   /usr/lib/python2.2/lib-old/cmpcache.pys   sig2 s   c    s¥   6 7 9 d d } : t |  d ƒ } ; t | d ƒ } < xd < d oY = | i | ƒ } > | i | ƒ } ? | | j o ? d Sn @ | o @ d Sn q= Wd S(   s   Compare two files, really.i   i   s   rbi   i    N(	   s   bufsizes   opens   f1s   fp1s   f2s   fp2s   reads   b1s   b2(   s   f1s   f2s   fp1s   b1s   b2s   fp2s   bufsize(    (    s&   /usr/lib/python2.2/lib-old/cmpcache.pys   do_cmp6 s    
  (   s   __doc__s   oss   stats	   statcaches   caches   cmps   sigs   do_cmp(   s   sigs	   statcaches   caches   oss   do_cmps   cmp(    (    s&   /usr/lib/python2.2/lib-old/cmpcache.pys   ?	 s   
	