Wc'cs ddlZddlZddlmZddlmZgdZiZdZgdZ dZ dd Z d Z d Z Gd d ZddZee fdZdZdZedkr edSdS)N) filterfalse) GenericAlias) clear_cachecmpdircmpcmpfilesDEFAULT_IGNORESi )ZRCSZCVSZtagsz.gitz.hgz.bzrZ_darcsZ __pycache__cs4 tjdSN)_cacheZclear /usr/lib64/python3.12/filecmp.pyrrs" LLNNNNr Tcs ttj|}ttj|}|dtjks|dtjkrdS|r||krdS|d|dkrdStj ||||f}|>t ||}ttdkr t|t||||f<|S)NrFTid) _sigosstatZS_IFREGr Zget_do_cmplenr)f1f2shallowZs1Zs2Zoutcomes r rrs, bggbk B bggbk B !u 1 5 5uw288t !u1~~ujj"b"b)*G"b/ v;   MM!(r2r2~ Nr csrtj|j|j|jfSr)rS_IFMTst_modeZst_sizeZst_mtime)Zst r rrFs* KK # JJ KK r csDt}t|d5}t|d5} |j|}|j|}||kr dddddddS|s dddddddSW#1swYnxYwddddS#1swYdSxYw)NZrbTF)BUFSIZEZopenZread)rrZbufsizeZfp1Zfp2Zb1Zb2s r rrKs^G b$3R#'"B'"BRxx  2s4B-A> B&A>) B=A>>B BBcseZdZ ddZdZdZdZdZdZdZ d Z d Z d Z e eeeeeeeeeeee Zd ZeeZdS)rNcs||_||_|(tjtjg|_n||_|t |_dS||_dSr)leftrightrZcurdirZpardirhiderignore)selfabrr r __init__zdircmp.__init__|sM  <BII.DIIDI >)DKKK DKKKr csttj|j|j|j z|_ttj|j|j|j z|_|j j|jjdSr) _filterrZlistdirrrr left_listr right_listsortrrr phase0z dircmp.phase0s DII!6!%4;;!68!"**TZZ"8"&))DKK"79  r c sttttjj |j |j }ttttjj |j|j}tt|jt|j||_ tt|jt|j||_tt|jt|j||_dSr)dictZzipZmaprpathZnormcaser$r%listZ __getitem__Zfilter __contains__commonr left_only right_only)rrr s r phase1z dircmp.phase1s S))4>>:DNNK L S))4??;T__M N3q}}fQ^^Q.GHI c!--Q^^Q1OPQs1==+anna2PQRr csg|_g|_g|_|jD]}tj j |j|}tj j |j|}d} t j|} t j|}|rtjj}tjj}||kr|jj|tj|r|jj|*tj|r|jj|_|jj|}|jj|dS#t$rd}Y6wxYw#t$rd}Y1wxYw)NTF) common_dirs common_files common_funnyr-rr*joinrrrOSErrorrrappendZS_ISDIRZS_ISREG) rxZa_pathZb_pathZokZa_statZb_statZa_typeZb_types r phase2z dircmp.phase2s , ,AWW\\$))Q/FWW\\$**a0FB   rV^^4V^^4V##%%,,Q///\\&))$$++A...\\&))%%,,Q///%%,,Q///!!((+++9 , ,         s$F?G? GG G"!G"cst|j|j|j}|\|_|_|_dSr)rrrr2 same_files diff_files funny_files)rZxx r phase3z dircmp.phase3s7 diiT->-> ?=?:$*:*:*:r csPi|_|jD]}tjj |j |}tjj |j |}|j|||j|j|j|<dSr) subdirsr1rr*r4rrZ __class__rr)rr7Za_xZb_xs r phase4z dircmp.phase4s  !! P PA'',,tyy!,C'',,tzz1-C#~~c3 TYYODLLOO P Pr cs|j|jjD]}|jdSr)r?r>valuesphase4_closurerZsdr<r rAzdircmp.phase4_closuresE ,,%%'  B        r cstd|j|j|jr?|jj td|jd|j|j r?|j j td|jd|j |j r3|j j td|j |jr3|jj td|j|jr3|jj td|j|jr3|jj td|j|jr5|jj td|jdSdS) NZdiffzOnly inz:zIdentical files :zDiffering files :zTrouble with common files :zCommon subdirectories :zCommon funny cases :) printrrr.r&r/r9r:r;r1r3r'rr reportz dircmp.reports fdii,, >>> NN   ! ! )TYYT^^ < < ??? OO " " )TZZdoo > > ??? OO " " %t 7 7 ??? OO " " %t 7 7        ! ! # # /1A1A B B        ! ! # # +T-=-= > >        " " $ $ ($*;*; < < < <  r cs|j|jjD]}t|j!dSr)rDr>r@rCrBr<r report_partial_closurezdircmp.report_partial_closuresG ,,%%'  B GG IIKKK  r cs|j|jjD]}t|j !dSr)rDr>r@rCreport_full_closurerBr<r rFzdircmp.report_full_closuresL ,,%%' % %B GG  " " $ $ $ % %r ) r>r9r:r;r1r2r3r-r.r/r$r%cs||jvr t||j||t||Sr) methodmapZAttributeErrorZgetattr)rZattrr<r __getattr__zdircmp.__getattr__s? t~~ % % & &tT""tT""r )NN)__name__Z __module__Z __qualname__r"r(r0r8r=r?rArDrErFr)rGrHZ classmethodrZ__class_getitem__r r r rrXs! F ! ! ! !SSS!,!,!,F@@@ P P P   ===2 %%% V &6v!'f6"f%& ::I ### $ L1r rcs gggf}|D]k}tjj||}tjj||}|t|||j |m|Sr)rr*r4_cmpr6)rr r-rZresr7ZaxZbxs r rrsr  r2,C -- WW\\!Q  WW\\!Q  DR !"))!,,, Jr csL ||||| S#t$rYdSwxYw)N)r5)rr Zshabsrr!r rJrJsC3ss1a}%%% qqs  ##csHtt|j|Sr)r+rr,)ZflistZskipr<r r#r#&s  D--u5 66r cs(ddl}ddl}|j|jddd\}}t|dkr|j ddt |d|d}d|vr|j dS|jdS)Nrr ZrrKzneed exactly two args)z-rZ)sysgetoptZargvrZ GetoptErrorrrFrD)rMrNZoptionsZargsZddr!r demorO,sJJJMMMMM#((12,4MGT 4yA~~  !8$?? Qa !BW      r Z__main__)T)rrZ itertoolsrZtypesrZ__all__r rrrrrrrrrLrJr#rOrIr r r rPsG  !!!!!! I I I  JJJ&&&&P   g2g2g2g2g2g2g2T6777    zDFFFFr