a _æh('ã@s®dZddlZddlZddlmZddlmZgd¢ZiZdZ gd¢Z dd „Z dd d „Z d d„Z dd„ZGdd„dƒZddd„Zee fdd„Zdd„Zdd„Zedkrª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)Ú GenericAlias)Ú clear_cacheÚcmpÚdircmpÚcmpfilesÚDEFAULT_IGNORESi )ÚRCSÚCVSÚtagsz.gitz.hgz.bzrÚ_darcsÚ __pycache__cCs t ¡dS)zClear the filecmp cache.N)Ú_cacheÚclear©rrú(/opt/imh-python/lib/python3.9/filecmp.pyrsrTcCsª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||_||_|dur$tjtjg|_n||_|dur:t|_n||_dSr!)ÚleftÚrightrÚcurdirÚpardirÚhiderÚignore)ÚselfÚaÚbr5r4rrrÚ__init__zszdircmp.__init__cCsPtt |j¡|j|jƒ|_tt |j¡|j|jƒ|_|j  ¡|j  ¡dSr!) Ú_filterrÚlistdirr0r4r5Ú left_listr1Ú right_listÚsort©r6rrrÚ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Únormcaser<r=ÚlistÚ __getitem__ÚfilterÚ __contains__ÚcommonrÚ left_onlyÚ right_only)r6r7r8rrrÚphase1Žs z dircmp.phase1c Csg|_g|_g|_|jD]ð}tj |j|¡}tj |j|¡}d}zt  |¡}Wnt ydd}Yn0zt  |¡}Wnt yŠd}Yn0|rüt   |j ¡}t   |j ¡}||kr¾|j  |¡nrLr_r`rarNrPr?rrrÚreportËs,           z dircmp.reportcCs*| ¡|j ¡D]}tƒ| ¡qdSr!)rordrhrnrjrrrÚreport_partial_closureäszdircmp.report_partial_closurecCs*| ¡|j ¡D]}tƒ| ¡qdSr!)rordrhrnÚreport_full_closurerjrrrrqêszdircmp.report_full_closure) rdr_r`rarNrOrPrJrKrLr<r=cCs*||jvrt|ƒ‚|j||ƒt||ƒSr!)Ú methodmapÚAttributeErrorÚgetattr)r6ÚattrrrrÚ __getattr__ös zdircmp.__getattr__)NN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r9r@rMr^rcrgrirorprqrArrrvÚ classmethodrÚ__class_getitem__rrrrrXs&! # ürcCsJgggf}|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. )rrDrQÚ_cmprS)r7r8rJrÚresrVÚaxÚbxrrrrÿs rcCs.z|||||ƒƒ WSty(YdS0dS)Né)rR)r7r8ÚshÚabsrrrrr}s r}cCstt|j|ƒƒSr!)rFrrI)ÚflistÚskiprrrr:#sr:cCsrddl}ddl}| |jdd…d¡\}}t|ƒdkrB| dd¡‚t|d|dƒ}d|vrf| ¡n| ¡dS)NrrÚrrzneed exactly two args)z-rÚ)ÚsysÚgetoptÚargvrÚ GetoptErrorrrqro)rˆr‰ÚoptionsÚargsÚddrrrÚdemo)s   rÚ__main__)T)T)rzrrÚ itertoolsrÚtypesrÚ__all__rr(rrrrrrrrƒr}r:rrwrrrrÚs(    ( (