Ë
    òT•jË'  ã                   ó°   — d Z ddlZddlZddlmZ ddlmZ g d¢Zi ZdZ	g d¢Z
d„ Zdd	„Zd
„ Zd„ Z G d„ d«      Zdd„Zeefd„Zd„ Zd„ Zedk(  r e«        yy)z³Utilities for comparing files and directories.

Classes:
    dircmp

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

é    N)Úfilterfalse)ÚGenericAlias)Úclear_cacheÚcmpÚdircmpÚcmpfilesÚDEFAULT_IGNORESi    )ÚRCSÚCVSÚtagsz.gitz.hgz.bzrÚ_darcsÚ__pycache__c                  ó,   — t         j                  «        y)zClear the filecmp cache.N)Ú_cacheÚclear© ó    ú/usr/lib/python3.12/filecmp.pyr   r      s   € ä
‡L�L…Nr   c                 ó   — t        t        j                  | «      «      }t        t        j                  |«      «      }|d   t        j                  k7  s|d   t        j                  k7  ry|r||k(  ry|d   |d   k7  ryt        j                  | |||f«      }|€5t        | |«      }t        t        «      dkD  r
t        «        |t        | |||f<   |S )aM  Compare two files.

    Arguments:

    f1 -- First file name

    f2 -- Second file name

    shallow -- treat files as identical if their stat signatures (type, size,
               mtime) are identical. Otherwise, files are considered different
               if their sizes or contents differ.  [default: True]

    Return value:

    True if the files are the same, False otherwise.

    This function uses a cache for past comparisons and the results,
    with cache entries invalidated if their stat information
    changes.  The cache may be cleared by calling clear_cache().

    r   FTé   éd   )	Ú_sigÚosÚstatÚS_IFREGr   ÚgetÚ_do_cmpÚlenr   )Úf1Úf2ÚshallowÚs1Ús2Úoutcomes         r   r   r      s·   € ô. 
Œb�g‰g�b‹kÓ	€BÜ	Œb�g‰g�b‹kÓ	€BØ	ˆ!�u”—‘Ò  1¡¬¯©Ò 5ØÙ�2˜’8ØØ	ˆ!�u��1‘‚~Øä�j‰j˜"˜b " bÐ)Ó*€GØ€Ü˜"˜b“/ˆÜŒv‹;˜ÒÜŒMØ!(Œˆr�2�r˜2ˆ~ÑØ€Nr   c                 ón   — t        j                  | j                  «      | j                  | j                  fS ©N)r   ÚS_IFMTÚst_modeÚst_sizeÚst_mtime)Ústs    r   r   r   F   s*   € Ü�K‰K˜Ÿ
™
Ó#Ø�J‰JØ�K‰Kðð r   c                 ó"  — t         }t        | d«      5 }t        |d«      5 }	 |j                  |«      }|j                  |«      }||k7  r	 d d d «       d d d «       y|s	 d d d «       d d d «       yŒN# 1 sw Y   nxY wd d d «       y # 1 sw Y   y xY w)NÚrbTF)ÚBUFSIZEÚopenÚread)r   r    ÚbufsizeÚfp1Úfp2Úb1Úb2s          r   r   r   K   s“   € Ü€GÜ	ˆb�$‹ð ˜3¤ R¨£ð °#ØØ—‘˜'Ó"ˆBØ—‘˜'Ó"ˆBØ�RŠxØ÷÷ ð ñ Ø÷÷ ð Ø÷ð ú÷ ÷ ñ ús4   “B *A0Á
BÁA0ÁBÁ/A0Á0A9	Á5BÂBc                   óŒ   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Z ee	eeeeeeeeeee¬«      Zd„ Z ee«      Zy)r   a®  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 DEFAULT_IGNORES.
      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 instances (or MyDirCmp instances if this
       object is of type MyDirCmp, a subclass of dircmp), keyed by names
       in common_dirs.
     Nc                 ó¨   — || _         || _        |€&t        j                  t        j                  g| _        n|| _        |€t        | _        y || _        y r&   )ÚleftÚrightr   ÚcurdirÚpardirÚhider	   Úignore)ÚselfÚaÚbr=   r<   s        r   Ú__init__zdircmp.__init__|   sC   € ØˆŒ	ØˆŒ
Øˆ<ÜŸ™¤B§I¡IÐ.ˆD�IàˆDŒIØˆ>Ü)ˆD�Kà ˆD�Kr   c                 ó€  — t        t        j                  | j                  «      | j                  | j
                  z   «      | _        t        t        j                  | j                  «      | j                  | j
                  z   «      | _        | j                  j                  «        | j                  j                  «        y r&   )
Ú_filterr   Úlistdirr8   r<   r=   Ú	left_listr9   Ú
right_listÚsort©r>   s    r   Úphase0zdircmp.phase0ˆ   sx   € Ü ¤§¡¨D¯I©IÓ!6Ø!%§¡¨4¯;©;Ñ!6ó8ˆŒä!¤"§*¡*¨T¯Z©ZÓ"8Ø"&§)¡)¨D¯K©KÑ"7ó9ˆŒà�‰×ÑÔØ�‰×ÑÕr   c           	      ó€  — 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                  |«      «      «      | _        y r&   )ÚdictÚzipÚmapr   ÚpathÚnormcaserE   rF   ÚlistÚ__getitem__ÚfilterÚ__contains__Úcommonr   Ú	left_onlyÚ
right_only)r>   r?   r@   s      r   Úphase1zdircmp.phase1�   s¼   € Ü””SœŸ™×)Ñ)¨4¯>©>Ó:¸D¿N¹NÓKÓLˆÜ””SœŸ™×)Ñ)¨4¯?©?Ó;¸T¿_¹_ÓMÓNˆÜœ3˜qŸ}™}¬f°Q·^±^ÀQÓ.GÓHÓIˆŒÜœc !§-¡-´¸Q¿^¹^ÈQÓ1OÓPÓQˆŒÜœs 1§=¡=´+¸a¿n¹nÈaÓ2PÓQÓRˆ�r   c                 óš  — g | _         g | _        g | _        | j                  D �]‚  }t        j
                  j                  | j                  |«      }t        j
                  j                  | j                  |«      }d}	 t	        j                  |«      }	 t	        j                  |«      }|ràt        j                  j                  «      }t        j                  j                  «      }||k7  r| j                  j                  |«       Œçt        j                  |«      r| j                   j                  |«       �Œt        j                  |«      r| j                  j                  |«       �ŒK| j                  j                  |«       �Œh| j                  j                  |«       �Œ… y # t        $ r d}Y �Œ%w xY w# t        $ r d}Y �Œ!w xY w)NTF)Úcommon_dirsÚcommon_filesÚcommon_funnyrT   r   rN   Újoinr8   r9   r   ÚOSErrorr'   r(   ÚappendÚS_ISDIRÚS_ISREG)	r>   ÚxÚa_pathÚb_pathÚokÚa_statÚb_statÚa_typeÚb_types	            r   Úphase2zdircmp.phase2—   s^  € ØˆÔØˆÔØˆÔà—‘ó 	,ˆAÜ—W‘W—\‘\ $§)¡)¨QÓ/ˆFÜ—W‘W—\‘\ $§*¡*¨aÓ0ˆFàˆBðÜŸ™ ›�ðÜŸ™ ›�ñ
 ÜŸ™ V§^¡^Ó4�ÜŸ™ V§^¡^Ó4�Ø˜VÒ#Ø×%Ñ%×,Ñ,¨QÕ/Ü—\‘\ &Ô)Ø×$Ñ$×+Ñ+¨AÖ.Ü—\‘\ &Ô)Ø×%Ñ%×,Ñ,¨QÖ/à×%Ñ%×,Ñ,¨QÖ/à×!Ñ!×(Ñ(¨Ö+ñ9	,øô ò à“ðûô
 ò à“ðús$   Á=F)ÂF;Æ)F8Æ7F8Æ;G
Ç	G
c                 ó„   — t        | j                  | j                  | j                  «      }|\  | _        | _        | _        y r&   )r   r8   r9   rZ   Ú
same_filesÚ
diff_filesÚfunny_files)r>   Úxxs     r   Úphase3zdircmp.phase3º   s1   € Ü�d—i‘i §¡¨T×->Ñ->Ó?ˆØ=?Ñ:ˆŒ˜œ¨$Õ*:r   c                 óF  — i | _         | j                  D ]‹  }t        j                  j	                  | j
                  |«      }t        j                  j	                  | j                  |«      }| j                  ||| j                  | j                  «      | j                   |<   Œ� y r&   )
ÚsubdirsrY   r   rN   r\   r8   r9   Ú	__class__r=   r<   )r>   ra   Úa_xÚb_xs       r   Úphase4zdircmp.phase4¾   sv   € ð
 ˆŒØ×!Ñ!ò 	PˆAÜ—'‘'—,‘,˜tŸy™y¨!Ó,ˆCÜ—'‘'—,‘,˜tŸz™z¨1Ó-ˆCØ#Ÿ~™~¨c°3¸¿¹ÀTÇYÁYÓOˆD�L‰L˜ŠOñ	Pr   c                 ó‚   — | j                  «        | j                  j                  «       D ]  }|j                  «        Œ y r&   )ru   rq   ÚvaluesÚphase4_closure©r>   Úsds     r   rx   zdircmp.phase4_closureÉ   s3   € Ø�‰ŒØ—,‘,×%Ñ%Ó'ò 	 ˆBØ×ÑÕñ	 r   c                 óÀ  — t        d| j                  | j                  «       | j                  r<| j                  j	                  «        t        d| j                  d| j                  «       | j
                  r<| j
                  j	                  «        t        d| j                  d| j
                  «       | j                  r0| j                  j	                  «        t        d| j                  «       | j                  r0| j                  j	                  «        t        d| j                  «       | j                  r0| j                  j	                  «        t        d| j                  «       | j                  r0| j                  j	                  «        t        d| j                  «       | j                  r1| j                  j	                  «        t        d| j                  «       y y )	NÚdiffzOnly inú:zIdentical files :zDiffering files :zTrouble with common files :zCommon subdirectories :zCommon funny cases :)Úprintr8   r9   rU   rG   rV   rk   rl   rm   rY   r[   rH   s    r   Úreportzdircmp.reportÎ   sE  € äˆf�d—i‘i §¡Ô,Ø�>Š>Ø�N‰N×ÑÔ!Ü�)˜TŸY™Y¨¨T¯^©^Ô<Ø�?Š?Ø�O‰O× Ñ Ô"Ü�)˜TŸZ™Z¨¨d¯o©oÔ>Ø�?Š?Ø�O‰O× Ñ Ô"ÜÐ% t§¡Ô7Ø�?Š?Ø�O‰O× Ñ Ô"ÜÐ% t§¡Ô7Ø×ÒØ×Ñ×!Ñ!Ô#ÜÐ/°×1AÑ1AÔBØ×ÒØ×Ñ×!Ñ!Ô#ÜÐ+¨T×-=Ñ-=Ô>Ø×ÒØ×Ñ×"Ñ"Ô$ÜÐ(¨$×*;Ñ*;Õ<ð r   c                 ó–   — | j                  «        | j                  j                  «       D ]  }t        «        |j                  «        Œ y r&   )r   rq   rw   r~   ry   s     r   Úreport_partial_closurezdircmp.report_partial_closureç   s5   € Ø�‰ŒØ—,‘,×%Ñ%Ó'ò 	ˆBÜŒGØ�I‰I�Kñ	r   c                 ó–   — | j                  «        | j                  j                  «       D ]  }t        «        |j	                  «        Œ y r&   )r   rq   rw   r~   Úreport_full_closurery   s     r   rƒ   zdircmp.report_full_closureí   s8   € Ø�‰ŒØ—,‘,×%Ñ%Ó'ò 	%ˆBÜŒGØ×"Ñ"Õ$ñ	%r   )rq   rk   rl   rm   rY   rZ   r[   rT   rU   rV   rE   rF   c                 óv   — || j                   vrt        |«      ‚ | j                   |   | «       t        | |«      S r&   )Ú	methodmapÚAttributeErrorÚgetattr)r>   Úattrs     r   Ú__getattr__zdircmp.__getattr__ù   s9   € Ø�t—~‘~Ñ%Ü  Ó&Ð&Øˆ�‰�tÑ˜TÔ"Ü�t˜TÓ"Ð"r   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rA   rI   rW   ri   ro   ru   rx   r   r�   rƒ   rK   r…   r‰   Úclassmethodr   Ú__class_getitem__r   r   r   r   r   X   sx   „ ñ!	óF
!òòSò!,òF@ò	Pò ò
=ò2ò%ñ ˜VØ &°6ÀvØ!'°fÈ6Ø"¨fÀØ%°&ô	:€Iò#ñ $ LÓ1Ñr   r   c                 óÜ   — g g g f}|D ]a  }t         j                  j                  | |«      }t         j                  j                  ||«      }|t        |||«         j	                  |«       Œc |S )a]  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.

    )r   rN   r\   Ú_cmpr^   )r?   r@   rT   r!   Úresra   ÚaxÚbxs           r   r   r     si   € ð ˆr�2ˆ,€CØò -ˆÜ�W‰W�\‰\˜!˜QÓˆÜ�W‰W�\‰\˜!˜QÓˆØŒD��R˜Ó!Ñ"×)Ñ)¨!Õ,ð-ð €Jr   c                 óD   — 	  | || ||«      «       S # t         $ r Y yw xY w)Né   )r]   )r?   r@   ÚshÚabsr   s        r   r‘   r‘     s/   € ðÙ‘s˜1˜a “}Ó%Ð%Ð%øÜò Ùðús   ‚ “	žc                 ó@   — t        t        |j                  | «      «      S r&   )rP   r   rS   )ÚflistÚskips     r   rC   rC   &  s   € Ü”˜D×-Ñ-¨uÓ5Ó6Ð6r   c                  ó  — dd l } dd l}|j                  | j                  dd  d«      \  }}t        |«      dk7  r|j	                  dd «      ‚t        |d   |d   «      }d|v r|j                  «        y |j                  «        y )Nr   r   Úrr–   zneed exactly two args)z-rÚ )ÚsysÚgetoptÚargvr   ÚGetoptErrorr   rƒ   r   )rŸ   r    ÚoptionsÚargsÚdds        r   Údemor¦   ,  sv   € ÛÛØ—M‘M #§(¡(¨1¨2 ,°Ó4�M€GˆTÜ
ˆ4ƒy�A‚~Ø× Ñ Ð!8¸$Ó?Ð?Ü	��Q‘˜˜a™Ó	!€BØ�WÑØ
×ÑÕ à
�	‰	�r   Ú__main__)T)r�   r   r   Ú	itertoolsr   Útypesr   Ú__all__r   r.   r	   r   r   r   r   r   r   r˜   r‘   rC   r¦   rŠ   r   r   r   ú<module>r«      s€   ðñ
ó 
Û Ý !Ý â
I€à	€Ø
€òJ€òó&òPò
	÷g2ñ g2óTð6  ó ò7ò
ð ˆzÒÙ…Fð r   