;
Κβ"Ic               @   sΐ   d  Z  d d l Z d d l Z d d l m Z d d d g Z i  Z d Z d	 d
  Z d   Z	 d   Z
 Gd   d  Z d	 d  Z e e d  Z d   Z d   Z e d k o e   n d S(   u   Utilities for comparing files and directories.

Classes:
    dircmp

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

i    N(   u   filterfalseu   cmpu   dircmpu   cmpfilesi   i   i   c             C   sψ   t  t j |    } t  t j |   } | d t j k p | d t j k o d S| o | | k o d S| d | d k o d St j |  | f  } | o& | | f | d d  k o	 | d St |  |  } | | | f t |  | f <| S(   u  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   Ni   FT(	   u   _sigu   osu   statu   S_IFREGu   Falseu   Trueu   _cacheu   getu   _do_cmp(   u   f1u   f2u   shallowu   s1u   s2u   resultu   outcome(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   cmp   s    ($	c             C   s   t  j |  j  |  j |  j f S(   N(   u   statu   S_IFMTu   st_modeu   st_sizeu   st_mtime(   u   st(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   _sig:   s    c             C   sj   t  } t |  d  } t | d  } x? | j |  } | j |  } | | k o d S| p d Sq' d  S(   Nu   rbFT(   u   BUFSIZEu   openu   readu   Falseu   True(   u   f1u   f2u   bufsizeu   fp1u   fp2u   b1u   b2(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   _do_cmp?   s    c             B   sΞ   |  Ee  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 d S(   uQ  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  k o t j t j g |  _ n
 | |  _ | d  k o d d d g |  _ n
 | |  _ d  S(   Nu   RCSu   CVSu   tags(   u   leftu   rightu   Noneu   osu   curdiru   pardiru   hideu   ignore(   u   selfu   au   bu   ignoreu   hide(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   __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(
   u   _filteru   osu   listdiru   leftu   hideu   ignoreu	   left_listu   rightu
   right_listu   sort(   u   self(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   phase0{   s    c             C   sΝ   t  t t t j j |  j  |  j   } t  t t t j j |  j  |  j   } t t | j	 t
 | j |    |  _ t t | j	 t | j |    |  _ t t | j	 t | j |    |  _ d  S(   N(   u   dictu   zipu   mapu   osu   pathu   normcaseu	   left_listu
   right_listu   listu   __getitem__u   filteru   __contains__u   commonu   filterfalseu	   left_onlyu
   right_only(   u   selfu   au   b(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   phase1   s
    **''c       
      C   s­  g  |  _  g  |  _ g  |  _ x|  j D]} t j j |  j |  } t j j |  j |  } d } y t j	 |  } Wn0 t j
 k
 o! } z d } WYd  d  } ~ Xn Xy t j	 |  } Wn0 t j
 k
 o! } z d } WYd  d  } ~ Xn X| o‘ t	 j | j  } t	 j | j  }	 | |	 k o |  j j |  q₯t	 j |  o |  j  j |  q₯t	 j |  o |  j j |  q₯|  j j |  q% |  j j |  q% Wd  S(   Ni   i    (   u   common_dirsu   common_filesu   common_funnyu   commonu   osu   pathu   joinu   leftu   rightu   statu   erroru   S_IFMTu   st_modeu   appendu   S_ISDIRu   S_ISREG(
   u   selfu   xu   a_pathu   b_pathu   oku   a_statu   whyu   b_statu   a_typeu   b_type(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   phase2   s6    			
 c             C   s7   t  |  j |  j |  j  } | \ |  _ |  _ |  _ d  S(   N(   u   cmpfilesu   leftu   rightu   common_filesu
   same_filesu
   diff_filesu   funny_files(   u   selfu   xx(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   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(
   u   subdirsu   common_dirsu   osu   pathu   joinu   leftu   rightu   dircmpu   ignoreu   hide(   u   selfu   xu   a_xu   b_x(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   phase4±   s    	
 c             C   s2   |  j    x! |  j j   D] } | j   q Wd  S(   N(   u   phase4u   subdirsu   valuesu   phase4_closure(   u   selfu   sd(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   phase4_closure»   s    
 c             C   sY  t  d |  j |  j  |  j o* |  j j   t  d |  j d |  j  n |  j o* |  j j   t  d |  j d |  j  n |  j o! |  j j   t  d |  j  n |  j o! |  j j   t  d |  j  n |  j o! |  j j   t  d |  j  n |  j	 o! |  j	 j   t  d |  j	  n |  j
 o! |  j
 j   t  d |  j
  n d  S(	   Nu   diffu   Only inu   :u   Identical files :u   Differing files :u   Trouble with common files :u   Common subdirectories :u   Common funny cases :(   u   printu   leftu   rightu	   left_onlyu   sortu
   right_onlyu
   same_filesu
   diff_filesu   funny_filesu   common_dirsu   common_funny(   u   self(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   reportΐ   s,    






c             C   s9   |  j    x( |  j j   D] } t   | j    q Wd  S(   N(   u   reportu   subdirsu   valuesu   print(   u   selfu   sd(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   report_partial_closureΩ   s
    
 c             C   s9   |  j    x( |  j j   D] } t   | j   q Wd  S(   N(   u   reportu   subdirsu   valuesu   printu   report_full_closure(   u   selfu   sd(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   report_full_closureί   s
    
 u   subdirsu
   same_filesu
   diff_filesu   funny_filesu   common_dirsu   common_filesu   common_funnyu   commonu	   left_onlyu
   right_onlyu	   left_listu
   right_listc             C   s>   | |  j  k o t |   n |  j  | |   t |  |  S(   N(   u	   methodmapu   AttributeErroru   getattr(   u   selfu   attr(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   __getattr__λ   s    N(   u   __name__u
   __module__u   __doc__u   Noneu   __init__u   phase0u   phase1u   phase2u   phase3u   phase4u   phase4_closureu   reportu   report_partial_closureu   report_full_closureu   dictu	   methodmapu   __getattr__(   u
   __locals__(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   dircmpM   s"   
 			#		
				c             C   sk   g  g  g  f } xU | D]M } t  j j |  |  } t  j j | |  } | t | | |  j |  q W| S(   u]  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.

    (   u   osu   pathu   joinu   _cmpu   append(   u   au   bu   commonu   shallowu   resu   xu   axu   bx(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   cmpfilesρ   s     !c             C   s=   y | | |  | |   SWn t  j k
 o d SYn Xd  S(   Ni   (   u   osu   error(   u   au   bu   shu   absu   cmp(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   _cmp  s    c             C   s   t  t | j |    S(   N(   u   listu   filterfalseu   __contains__(   u   flistu   skip(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   _filter  s    c              C   s¦   d d  l  }  d d  l } | j |  j d d   d  \ } } t |  d k o | j d d    n t | d | d  } d | k o | j   n | j   d  S(	   Ni    i   u   ri   u   need exactly two argsu   -ru    (   u   -ru    (	   u   sysu   getoptu   argvu   lenu   GetoptErroru   Noneu   dircmpu   report_full_closureu   report(   u   sysu   getoptu   optionsu   argsu   dd(    (    u$   /mit/python/lib/python3.0/filecmp.pyu   demo  s    %u   __main__i    (   u   __doc__u   osu   statu	   itertoolsu   filterfalseu   __all__u   _cacheu   BUFSIZEu   cmpu   _sigu   _do_cmpu   dircmpu   cmpfilesu   absu   _cmpu   _filteru   demou   __name__(    (    (    u$   /mit/python/lib/python3.0/filecmp.pyu   <module>
   s    %		€			