grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026U iÛff&ã@s´dZddlZddlZddlmZdddddgZiZd Zd d d d ddddgZdd„Z d"dd„Z dd„Z dd„Z Gdd„dƒZ d#dd„Zee fdd„Zdd„Zdd „Zed!kr°eƒdS)$z³Utilities for comparing files and directories. Classes: dircmp Functions: cmp(f1, f2, shallow=True) -> int cmpfiles(a, b, common) -> ([], [], []) clear_cache() éN)Ú filterfalseÚ clear_cacheÚcmpÚdircmpÚcmpfilesÚDEFAULT_IGNORESi ZRCSZCVSZtagsz.gitz.hgz.bzrZ_darcsÚ __pycache__cCs t ¡dS)zClear the filecmp cache.N)Ú_cacheÚclear©r r ú,/opt/alt/python38/lib64/python3.8/filecmp.pyrsTcCsªtt |¡ƒ}tt |¡ƒ}|dtjks8|dtjkr 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. NcCsD||_||_|dkr$tjtjg|_n||_|dkr:t|_n||_dSr)ÚleftÚrightrÚcurdirÚpardirÚhiderÚignore)ÚselfÚaÚbr-r,r r r Ú__init__xszdircmp.__init__cCsPtt |j¡|j|jƒ|_tt |j¡|j|jƒ|_|j  ¡|j  ¡dSr) Ú_filterrÚlistdirr(r,r-Ú left_listr)Ú right_listÚsort©r.r r r Úphase0„s  ÿ  ÿ z dircmp.phase0cCsŠttttjj|jƒ|jƒƒ}ttttjj|jƒ|jƒƒ}tt|j t |j |ƒƒƒ|_ tt|j t |j |ƒƒƒ|_tt|j t |j |ƒƒƒ|_dSr)ÚdictÚzipÚmaprÚpathÚnormcaser4r5ÚlistÚ __getitem__ÚfilterÚ __contains__ÚcommonrÚ left_onlyÚ right_only)r.r/r0r r r Úphase1Œs z dircmp.phase1c Cs4g|_g|_g|_|jD�]}tj |j|¡}tj |j|¡}d}zt  |¡}Wn&t k rv}zd}W5d}~XYnXzt  |¡}Wn&t k r¬}zd}W5d}~XYnX|�r"t   |j ¡}t   |j ¡} || krâ|j  |¡n>t  |¡rú|j  |¡n&t  |¡�r|j  |¡n |j  |¡q|j  |¡qdS)Nr r)Ú common_dirsÚ common_filesÚ common_funnyrBrr<Újoinr(r)rÚOSErrorrrÚappendÚS_ISDIRÚS_ISREG) r.ÚxZa_pathZb_pathÚokZa_statZwhyZb_statZa_typeZb_typer r r Úphase2“s4     z dircmp.phase2cCs&t|j|j|jƒ}|\|_|_|_dSr)rr(r)rGÚ same_filesÚ diff_filesÚ funny_files)r.Zxxr r r Úphase3¶sz dircmp.phase3cCsNi|_|jD]<}tj |j|¡}tj |j|¡}t|||j|j ƒ|j|<q dSr) ÚsubdirsrFrr<rIr(r)rr-r,)r.rNZa_xZb_xr r r Úphase4ºs  z dircmp.phase4cCs$| ¡|j ¡D] }| ¡qdSr)rVrUÚvaluesÚphase4_closure©r.Zsdr r r rXÄszdircmp.phase4_closurecCsätd|j|jƒ|jr2|j ¡td|jd|jƒ|jrT|j ¡td|jd|jƒ|jrp|j ¡td|jƒ|jrŒ|j ¡td|jƒ|jr¨|j ¡td|jƒ|j rÄ|j  ¡td|j ƒ|j rà|j  ¡td|j ƒdS) NZdiffzOnly inú:zIdentical files :zDiffering files :zTrouble with common files :zCommon subdirectories :zCommon funny cases :) Úprintr(r)rCr6rDrQrRrSrFrHr7r r r ÚreportÉs,           z dircmp.reportcCs*| ¡|j ¡D]}tƒ| ¡qdSr)r\rUrWr[rYr r r Úreport_partial_closureâszdircmp.report_partial_closurecCs*| ¡|j ¡D]}tƒ| ¡qdSr)r\rUrWr[Úreport_full_closurerYr r r r^èszdircmp.report_full_closure) rUrQrRrSrFrGrHrBrCrDr4r5cCs*||jkrt|ƒ‚|j||ƒt||ƒSr)Ú methodmapÚAttributeErrorÚgetattr)r.Úattrr r r Ú __getattr__ôs zdircmp.__getattr__)NN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r1r8rErPrTrVrXr\r]r^r9r_rcr r r r rVs2! # ücCsJgggf}|D]6}tj ||¡}tj ||¡}|t|||ƒ |¡q|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. )rr<rIÚ_cmprK)r/r0rBrÚresrNZaxZbxr r r rús cCs0z|||||ƒƒ WStk r*YdSXdS)Né)rJ)r/r0ZshÚabsrr r r rhsrhcCstt|j|ƒƒSr)r>rrA)ZflistÚskipr r r r2sr2cCsrddl}ddl}| |jdd…d¡\}}t|ƒdkrB| dd¡‚t|d|dƒ}d|krf| ¡n| ¡dS)Nrr Úrrjzneed exactly two args)z-rÚ)ÚsysÚgetoptÚargvrZ GetoptErrorrr^r\)rorpZoptionsÚargsZddr r r Údemo$s   rsÚ__main__)T)T)rgrrÚ itertoolsrÚ__all__r r"rrrrrrrrkrhr2rsrdr r r r Ús6  ÿ ' %