You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"payload":{"allShortcutsEnabled":false,"fileTree":{"Lib":{"items":[{"name":"__phello__","path":"Lib/__phello__","contentType":"directory"},{"name":"asyncio","path":"Lib/asyncio","contentType":"directory"},{"name":"collections","path":"Lib/collections","contentType":"directory"},{"name":"concurrent","path":"Lib/concurrent","contentType":"directory"},{"name":"ctypes","path":"Lib/ctypes","contentType":"directory"},{"name":"curses","path":"Lib/curses","contentType":"directory"},{"name":"dbm","path":"Lib/dbm","contentType":"directory"},{"name":"distutils","path":"Lib/distutils","contentType":"directory"},{"name":"email","path":"Lib/email","contentType":"directory"},{"name":"encodings","path":"Lib/encodings","contentType":"directory"},{"name":"ensurepip","path":"Lib/ensurepip","contentType":"directory"},{"name":"html","path":"Lib/html","contentType":"directory"},{"name":"http","path":"Lib/http","contentType":"directory"},{"name":"idlelib","path":"Lib/idlelib","contentType":"directory"},{"name":"importlib","path":"Lib/importlib","contentType":"directory"},{"name":"json","path":"Lib/json","contentType":"directory"},{"name":"lib2to3","path":"Lib/lib2to3","contentType":"directory"},{"name":"logging","path":"Lib/logging","contentType":"directory"},{"name":"msilib","path":"Lib/msilib","contentType":"directory"},{"name":"multiprocessing","path":"Lib/multiprocessing","contentType":"directory"},{"name":"pydoc_data","path":"Lib/pydoc_data","contentType":"directory"},{"name":"re","path":"Lib/re","contentType":"directory"},{"name":"site-packages","path":"Lib/site-packages","contentType":"directory"},{"name":"sqlite3","path":"Lib/sqlite3","contentType":"directory"},{"name":"test","path":"Lib/test","contentType":"directory"},{"name":"tkinter","path":"Lib/tkinter","contentType":"directory"},{"name":"tomllib","path":"Lib/tomllib","contentType":"directory"},{"name":"turtledemo","path":"Lib/turtledemo","contentType":"directory"},{"name":"unittest","path":"Lib/unittest","contentType":"directory"},{"name":"urllib","path":"Lib/urllib","contentType":"directory"},{"name":"venv","path":"Lib/venv","contentType":"directory"},{"name":"wsgiref","path":"Lib/wsgiref","contentType":"directory"},{"name":"xml","path":"Lib/xml","contentType":"directory"},{"name":"xmlrpc","path":"Lib/xmlrpc","contentType":"directory"},{"name":"zoneinfo","path":"Lib/zoneinfo","contentType":"directory"},{"name":"__future__.py","path":"Lib/__future__.py","contentType":"file"},{"name":"__hello__.py","path":"Lib/__hello__.py","contentType":"file"},{"name":"_aix_support.py","path":"Lib/_aix_support.py","contentType":"file"},{"name":"_bootsubprocess.py","path":"Lib/_bootsubprocess.py","contentType":"file"},{"name":"_collections_abc.py","path":"Lib/_collections_abc.py","contentType":"file"},{"name":"_compat_pickle.py","path":"Lib/_compat_pickle.py","contentType":"file"},{"name":"_compression.py","path":"Lib/_compression.py","contentType":"file"},{"name":"_markupbase.py","path":"Lib/_markupbase.py","contentType":"file"},{"name":"_osx_support.py","path":"Lib/_osx_support.py","contentType":"file"},{"name":"_py_abc.py","path":"Lib/_py_abc.py","contentType":"file"},{"name":"_pydecimal.py","path":"Lib/_pydecimal.py","contentType":"file"},{"name":"_pyio.py","path":"Lib/_pyio.py","contentType":"file"},{"name":"_sitebuiltins.py","path":"Lib/_sitebuiltins.py","contentType":"file"},{"name":"_strptime.py","path":"Lib/_strptime.py","contentType":"file"},{"name":"_threading_local.py","path":"Lib/_threading_local.py","contentType":"file"},{"name":"_weakrefset.py","path":"Lib/_weakrefset.py","contentType":"file"},{"name":"abc.py","path":"Lib/abc.py","contentType":"file"},{"name":"aifc.py","path":"Lib/aifc.py","contentType":"file"},{"name":"antigravity.py","path":"Lib/antigravity.py","contentType":"file"},{"name":"argparse.py","path":"Lib/argparse.py","contentType":"file"},{"name":"ast.py","path":"Lib/ast.py","contentType":"file"},{"name":"asynchat.py","path":"Lib/asynchat.py","contentType":"file"},{"name":"asyncore.py","path":"Lib/asyncore.py","contentType":"file"},{"name":"base64.py","path":"Lib/base64.py","contentType":"file"},{"name":"bdb.py","path":"Lib/bdb.py","contentType":"file"},{"name":"bisect.py","path":"Lib/bisect.py","contentType":"file"},{"name":"bz2.py","path":"Lib/bz2.py","contentType":"file"},{"name":"cProfile.py","path":"Lib/cProfile.py","contentType":"file"},{"name":"calendar.py","path":"Lib/calendar.py","contentType":"file"},{"name":"cgi.py","path":"Lib/cgi.py","contentType":"file"},{"name":"cgitb.py","path":"Lib/cgitb.py","contentType":"file"},{"name":"chunk.py","path":"Lib/chunk.py","contentType":"file"},{"name":"cmd.py","path":"Lib/cmd.py","contentType":"file"},{"name":"code.py","path":"Lib/code.py","contentType":"file"},{"name":"codecs.py","path":"Lib/codecs.py","contentType":"file"},{"name":"codeop.py","path":"Lib/codeop.py","contentType":"file"},{"name":"colorsys.py","path":"Lib/colorsys.py","contentType":"file"},{"name":"compileall.py","path":"Lib/compileall.py","contentType":"file"},{"name":"configparser.py","path":"Lib/configparser.py","contentType":"file"},{"name":"contextlib.py","path":"Lib/contextlib.py","contentType":"file"},{"name":"contextvars.py","path":"Lib/contextvars.py","contentType":"file"},{"name":"copy.py","path":"Lib/copy.py","contentType":"file"},{"name":"copyreg.py","path":"Lib/copyreg.py","contentType":"file"},{"name":"crypt.py","path":"Lib/crypt.py","contentType":"file"},{"name":"csv.py","path":"Lib/csv.py","contentType":"file"},{"name":"dataclasses.py","path":"Lib/dataclasses.py","contentType":"file"},{"name":"datetime.py","path":"Lib/datetime.py","contentType":"file"},{"name":"decimal.py","path":"Lib/decimal.py","contentType":"file"},{"name":"difflib.py","path":"Lib/difflib.py","contentType":"file"},{"name":"dis.py","path":"Lib/dis.py","contentType":"file"},{"name":"doctest.py","path":"Lib/doctest.py","contentType":"file"},{"name":"enum.py","path":"Lib/enum.py","contentType":"file"},{"name":"filecmp.py","path":"Lib/filecmp.py","contentType":"file"},{"name":"fileinput.py","path":"Lib/fileinput.py","contentType":"file"},{"name":"fnmatch.py","path":"Lib/fnmatch.py","contentType":"file"},{"name":"fractions.py","path":"Lib/fractions.py","contentType":"file"},{"name":"ftplib.py","path":"Lib/ftplib.py","contentType":"file"},{"name":"functools.py","path":"Lib/functools.py","contentType":"file"},{"name":"genericpath.py","path":"Lib/genericpath.py","contentType":"file"},{"name":"getopt.py","path":"Lib/getopt.py","contentType":"file"},{"name":"getpass.py","path":"Lib/getpass.py","contentType":"file"},{"name":"gettext.py","path":"Lib/gettext.py","contentType":"file"},{"name":"glob.py","path":"Lib/glob.py","contentType":"file"},{"name":"graphlib.py","path":"Lib/graphlib.py","contentType":"file"},{"name":"gzip.py","path":"Lib/gzip.py","contentType":"file"},{"name":"hashlib.py","path":"Lib/hashlib.py","contentType":"file"},{"name":"heapq.py","path":"Lib/heapq.py","contentType":"file"},{"name":"hmac.py","path":"Lib/hmac.py","contentType":"file"},{"name":"imaplib.py","path":"Lib/imaplib.py","contentType":"file"},{"name":"imghdr.py","path":"Lib/imghdr.py","contentType":"file"},{"name":"imp.py","path":"Lib/imp.py","contentType":"file"},{"name":"inspect.py","path":"Lib/inspect.py","contentType":"file"},{"name":"io.py","path":"Lib/io.py","contentType":"file"},{"name":"ipaddress.py","path":"Lib/ipaddress.py","contentType":"file"},{"name":"keyword.py","path":"Lib/keyword.py","contentType":"file"},{"name":"linecache.py","path":"Lib/linecache.py","contentType":"file"},{"name":"locale.py","path":"Lib/locale.py","contentType":"file"},{"name":"lzma.py","path":"Lib/lzma.py","contentType":"file"},{"name":"mailbox.py","path":"Lib/mailbox.py","contentType":"file"},{"name":"mailcap.py","path":"Lib/mailcap.py","contentType":"file"},{"name":"mimetypes.py","path":"Lib/mimetypes.py","contentType":"file"},{"name":"modulefinder.py","path":"Lib/modulefinder.py","contentType":"file"},{"name":"netrc.py","path":"Lib/netrc.py","contentType":"file"},{"name":"nntplib.py","path":"Lib/nntplib.py","contentType":"file"},{"name":"ntpath.py","path":"Lib/ntpath.py","contentType":"file"},{"name":"nturl2path.py","path":"Lib/nturl2path.py","contentType":"file"},{"name":"numbers.py","path":"Lib/numbers.py","contentType":"file"},{"name":"opcode.py","path":"Lib/opcode.py","contentType":"file"},{"name":"operator.py","path":"Lib/operator.py","contentType":"file"},{"name":"optparse.py","path":"Lib/optparse.py","contentType":"file"},{"name":"os.py","path":"Lib/os.py","contentType":"file"},{"name":"pathlib.py","path":"Lib/pathlib.py","contentType":"file"},{"name":"pdb.py","path":"Lib/pdb.py","contentType":"file"},{"name":"pickle.py","path":"Lib/pickle.py","contentType":"file"},{"name":"pickletools.py","path":"Lib/pickletools.py","contentType":"file"},{"name":"pipes.py","path":"Lib/pipes.py","contentType":"file"},{"name":"pkgutil.py","path":"Lib/pkgutil.py","contentType":"file"},{"name":"platform.py","path":"Lib/platform.py","contentType":"file"},{"name":"plistlib.py","path":"Lib/plistlib.py","contentType":"file"},{"name":"poplib.py","path":"Lib/poplib.py","contentType":"file"},{"name":"posixpath.py","path":"Lib/posixpath.py","contentType":"file"},{"name":"pprint.py","path":"Lib/pprint.py","contentType":"file"},{"name":"profile.py","path":"Lib/profile.py","contentType":"file"},{"name":"pstats.py","path":"Lib/pstats.py","contentType":"file"},{"name":"pty.py","path":"Lib/pty.py","contentType":"file"},{"name":"py_compile.py","path":"Lib/py_compile.py","contentType":"file"},{"name":"pyclbr.py","path":"Lib/pyclbr.py","contentType":"file"},{"name":"pydoc.py","path":"Lib/pydoc.py","contentType":"file"},{"name":"queue.py","path":"Lib/queue.py","contentType":"file"},{"name":"quopri.py","path":"Lib/quopri.py","contentType":"file"},{"name":"random.py","path":"Lib/random.py","contentType":"file"},{"name":"reprlib.py","path":"Lib/reprlib.py","contentType":"file"},{"name":"rlcompleter.py","path":"Lib/rlcompleter.py","contentType":"file"},{"name":"runpy.py","path":"Lib/runpy.py","contentType":"file"},{"name":"sched.py","path":"Lib/sched.py","contentType":"file"},{"name":"secrets.py","path":"Lib/secrets.py","contentType":"file"},{"name":"selectors.py","path":"Lib/selectors.py","contentType":"file"},{"name":"shelve.py","path":"Lib/shelve.py","contentType":"file"},{"name":"shlex.py","path":"Lib/shlex.py","contentType":"file"},{"name":"shutil.py","path":"Lib/shutil.py","contentType":"file"},{"name":"signal.py","path":"Lib/signal.py","contentType":"file"},{"name":"site.py","path":"Lib/site.py","contentType":"file"},{"name":"smtpd.py","path":"Lib/smtpd.py","contentType":"file"},{"name":"smtplib.py","path":"Lib/smtplib.py","contentType":"file"},{"name":"sndhdr.py","path":"Lib/sndhdr.py","contentType":"file"},{"name":"socket.py","path":"Lib/socket.py","contentType":"file"},{"name":"socketserver.py","path":"Lib/socketserver.py","contentType":"file"},{"name":"sre_compile.py","path":"Lib/sre_compile.py","contentType":"file"},{"name":"sre_constants.py","path":"Lib/sre_constants.py","contentType":"file"},{"name":"sre_parse.py","path":"Lib/sre_parse.py","contentType":"file"},{"name":"ssl.py","path":"Lib/ssl.py","contentType":"file"},{"name":"stat.py","path":"Lib/stat.py","contentType":"file"},{"name":"statistics.py","path":"Lib/statistics.py","contentType":"file"},{"name":"string.py","path":"Lib/string.py","contentType":"file"},{"name":"stringprep.py","path":"Lib/stringprep.py","contentType":"file"},{"name":"struct.py","path":"Lib/struct.py","contentType":"file"},{"name":"subprocess.py","path":"Lib/subprocess.py","contentType":"file"},{"name":"sunau.py","path":"Lib/sunau.py","contentType":"file"},{"name":"symtable.py","path":"Lib/symtable.py","contentType":"file"},{"name":"sysconfig.py","path":"Lib/sysconfig.py","contentType":"file"},{"name":"tabnanny.py","path":"Lib/tabnanny.py","contentType":"file"},{"name":"tarfile.py","path":"Lib/tarfile.py","contentType":"file"},{"name":"telnetlib.py","path":"Lib/telnetlib.py","contentType":"file"},{"name":"tempfile.py","path":"Lib/tempfile.py","contentType":"file"},{"name":"textwrap.py","path":"Lib/textwrap.py","contentType":"file"},{"name":"this.py","path":"Lib/this.py","contentType":"file"},{"name":"threading.py","path":"Lib/threading.py","contentType":"file"},{"name":"timeit.py","path":"Lib/timeit.py","contentType":"file"},{"name":"token.py","path":"Lib/token.py","contentType":"file"},{"name":"tokenize.py","path":"Lib/tokenize.py","contentType":"file"},{"name":"trace.py","path":"Lib/trace.py","contentType":"file"},{"name":"traceback.py","path":"Lib/traceback.py","contentType":"file"},{"name":"tracemalloc.py","path":"Lib/tracemalloc.py","contentType":"file"},{"name":"tty.py","path":"Lib/tty.py","contentType":"file"},{"name":"turtle.py","path":"Lib/turtle.py","contentType":"file"},{"name":"types.py","path":"Lib/types.py","contentType":"file"},{"name":"typing.py","path":"Lib/typing.py","contentType":"file"},{"name":"uu.py","path":"Lib/uu.py","contentType":"file"},{"name":"uuid.py","path":"Lib/uuid.py","contentType":"file"},{"name":"warnings.py","path":"Lib/warnings.py","contentType":"file"},{"name":"wave.py","path":"Lib/wave.py","contentType":"file"},{"name":"weakref.py","path":"Lib/weakref.py","contentType":"file"},{"name":"webbrowser.py","path":"Lib/webbrowser.py","contentType":"file"},{"name":"xdrlib.py","path":"Lib/xdrlib.py","contentType":"file"},{"name":"zipapp.py","path":"Lib/zipapp.py","contentType":"file"},{"name":"zipfile.py","path":"Lib/zipfile.py","contentType":"file"},{"name":"zipimport.py","path":"Lib/zipimport.py","contentType":"file"}],"totalCount":202},"":{"items":[{"name":".azure-pipelines","path":".azure-pipelines","contentType":"directory"},{"name":".github","path":".github","contentType":"directory"},{"name":"Doc","path":"Doc","contentType":"directory"},{"name":"Grammar","path":"Grammar","contentType":"directory"},{"name":"Include","path":"Include","contentType":"directory"},{"name":"Lib","path":"Lib","contentType":"directory"},{"name":"Mac","path":"Mac","contentType":"directory"},{"name":"Misc","path":"Misc","contentType":"directory"},{"name":"Modules","path":"Modules","contentType":"directory"},{"name":"Objects","path":"Objects","contentType":"directory"},{"name":"PC","path":"PC","contentType":"directory"},{"name":"PCbuild","path":"PCbuild","contentType":"directory"},{"name":"Parser","path":"Parser","contentType":"directory"},{"name":"Programs","path":"Programs","contentType":"directory"},{"name":"Python","path":"Python","contentType":"directory"},{"name":"Tools","path":"Tools","contentType":"directory"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".gitattributes","path":".gitattributes","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile.pre.in","path":"Makefile.pre.in","contentType":"file"},{"name":"README.rst","path":"README.rst","contentType":"file"},{"name":"aclocal.m4","path":"aclocal.m4","contentType":"file"},{"name":"config.guess","path":"config.guess","contentType":"file"},{"name":"config.sub","path":"config.sub","contentType":"file"},{"name":"configure","path":"configure","contentType":"file"},{"name":"configure.ac","path":"configure.ac","contentType":"file"},{"name":"install-sh","path":"install-sh","contentType":"file"},{"name":"pyconfig.h.in","path":"pyconfig.h.in","contentType":"file"},{"name":"setup.py","path":"setup.py","contentType":"file"}],"totalCount":30}},"fileTreeProcessingTime":31.29655,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":81598961,"defaultBranch":"main","name":"cpython","ownerLogin":"python","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2017-02-10T19:23:51.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1525981?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"b6355d01353d859830502e0e3243b5b81e9e9821","listCacheKey":"v0:1748285546.0","canEdit":false,"refType":"tree","currentOid":"b6355d01353d859830502e0e3243b5b81e9e9821"},"path":"Lib/filecmp.py","currentUser":null,"blob":{"rawLines":["\"\"\"Utilities for comparing files and directories.","","Classes:"," dircmp","","Functions:"," cmp(f1, f2, shallow=True) -\u003e int"," cmpfiles(a, b, common) -\u003e ([], [], [])"," clear_cache()","","\"\"\"","","import os","import stat","from itertools import filterfalse","from types import GenericAlias","","__all__ = ['clear_cache', 'cmp', 'dircmp', 'cmpfiles', 'DEFAULT_IGNORES']","","_cache = {}","BUFSIZE = 8*1024","","DEFAULT_IGNORES = ["," 'RCS', 'CVS', 'tags', '.git', '.hg', '.bzr', '_darcs', '__pycache__']","","def clear_cache():"," \"\"\"Clear the filecmp cache.\"\"\""," _cache.clear()","","def cmp(f1, f2, shallow=True):"," \"\"\"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().",""," \"\"\"",""," s1 = _sig(os.stat(f1))"," s2 = _sig(os.stat(f2))"," if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG:"," return False"," if shallow and s1 == s2:"," return True"," if s1[1] != s2[1]:"," return False",""," outcome = _cache.get((f1, f2, s1, s2))"," if outcome is None:"," outcome = _do_cmp(f1, f2)"," if len(_cache) \u003e 100: # limit the maximum size of the cache"," clear_cache()"," _cache[f1, f2, s1, s2] = outcome"," return outcome","","def _sig(st):"," return (stat.S_IFMT(st.st_mode),"," st.st_size,"," st.st_mtime)","","def _do_cmp(f1, f2):"," bufsize = BUFSIZE"," with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2:"," while True:"," b1 = fp1.read(bufsize)"," b2 = fp2.read(bufsize)"," if b1 != b2:"," return False"," if not b1:"," return True","","# Directory comparison class.","#","class dircmp:"," \"\"\"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() -\u003e prints a report on the differences between dir1 and dir2"," or"," x.report_partial_closure() -\u003e prints report on differences between dir1"," and dir2, and reports on common immediate subdirectories."," x.report_full_closure() -\u003e 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."," \"\"\"",""," def __init__(self, a, b, ignore=None, hide=None): # Initialize"," self.left = a"," self.right = b"," if hide is None:"," self.hide = [os.curdir, os.pardir] # Names never to be shown"," else:"," self.hide = hide"," if ignore is None:"," self.ignore = DEFAULT_IGNORES"," else:"," self.ignore = ignore",""," def phase0(self): # Compare everything except common subdirectories"," self.left_list = _filter(os.listdir(self.left),"," self.hide+self.ignore)"," self.right_list = _filter(os.listdir(self.right),"," self.hide+self.ignore)"," self.left_list.sort()"," self.right_list.sort()",""," def phase1(self): # Compute common names"," a = dict(zip(map(os.path.normcase, self.left_list), self.left_list))"," b = dict(zip(map(os.path.normcase, self.right_list), self.right_list))"," self.common = list(map(a.__getitem__, filter(b.__contains__, a)))"," self.left_only = list(map(a.__getitem__, filterfalse(b.__contains__, a)))"," self.right_only = list(map(b.__getitem__, filterfalse(a.__contains__, b)))",""," def phase2(self): # Distinguish files, directories, funnies"," self.common_dirs = []"," self.common_files = []"," self.common_funny = []",""," for x in self.common:"," a_path = os.path.join(self.left, x)"," b_path = os.path.join(self.right, x)",""," ok = True"," try:"," a_stat = os.stat(a_path)"," except OSError:"," # print('Can\\'t stat', a_path, ':', why.args[1])"," ok = False"," try:"," b_stat = os.stat(b_path)"," except OSError:"," # print('Can\\'t stat', b_path, ':', why.args[1])"," ok = False",""," if ok:"," a_type = stat.S_IFMT(a_stat.st_mode)"," b_type = stat.S_IFMT(b_stat.st_mode)"," if a_type != b_type:"," self.common_funny.append(x)"," elif stat.S_ISDIR(a_type):"," self.common_dirs.append(x)"," elif stat.S_ISREG(a_type):"," self.common_files.append(x)"," else:"," self.common_funny.append(x)"," else:"," self.common_funny.append(x)",""," def phase3(self): # Find out differences between common files"," xx = cmpfiles(self.left, self.right, self.common_files)"," self.same_files, self.diff_files, self.funny_files = xx",""," def phase4(self): # Find out differences between common subdirectories"," # A new dircmp (or MyDirCmp if dircmp was subclassed) object is created"," # for each common subdirectory,"," # these are stored in a dictionary indexed by filename."," # The hide and ignore properties are inherited from the parent"," self.subdirs = {}"," for x in self.common_dirs:"," a_x = os.path.join(self.left, x)"," b_x = os.path.join(self.right, x)"," self.subdirs[x] = self.__class__(a_x, b_x, self.ignore, self.hide)",""," def phase4_closure(self): # Recursively call phase4() on subdirectories"," self.phase4()"," for sd in self.subdirs.values():"," sd.phase4_closure()",""," def report(self): # Print a report on the differences between a and b"," # Output format is purposely lousy"," print('diff', self.left, self.right)"," if self.left_only:"," self.left_only.sort()"," print('Only in', self.left, ':', self.left_only)"," if self.right_only:"," self.right_only.sort()"," print('Only in', self.right, ':', self.right_only)"," if self.same_files:"," self.same_files.sort()"," print('Identical files :', self.same_files)"," if self.diff_files:"," self.diff_files.sort()"," print('Differing files :', self.diff_files)"," if self.funny_files:"," self.funny_files.sort()"," print('Trouble with common files :', self.funny_files)"," if self.common_dirs:"," self.common_dirs.sort()"," print('Common subdirectories :', self.common_dirs)"," if self.common_funny:"," self.common_funny.sort()"," print('Common funny cases :', self.common_funny)",""," def report_partial_closure(self): # Print reports on self and on subdirs"," self.report()"," for sd in self.subdirs.values():"," print()"," sd.report()",""," def report_full_closure(self): # Report on self and subdirs recursively"," self.report()"," for sd in self.subdirs.values():"," print()"," sd.report_full_closure()",""," methodmap = dict(subdirs=phase4,"," same_files=phase3, diff_files=phase3, funny_files=phase3,"," common_dirs=phase2, common_files=phase2, common_funny=phase2,"," common=phase1, left_only=phase1, right_only=phase1,"," left_list=phase0, right_list=phase0)",""," def __getattr__(self, attr):"," if attr not in self.methodmap:"," raise AttributeError(attr)"," self.methodmap[attr](self)"," return getattr(self, attr)",""," __class_getitem__ = classmethod(GenericAlias)","","","def cmpfiles(a, b, common, shallow=True):"," \"\"\"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.",""," \"\"\""," res = ([], [], [])"," for x in common:"," ax = os.path.join(a, x)"," bx = os.path.join(b, x)"," res[_cmp(ax, bx, shallow)].append(x)"," return res","","","# Compare two files.","# Return:","# 0 for equal","# 1 for different","# 2 for funny cases (can't stat, etc.)","#","def _cmp(a, b, sh, abs=abs, cmp=cmp):"," try:"," return not abs(cmp(a, b, sh))"," except OSError:"," return 2","","","# Return a copy with items that occur in skip removed.","#","def _filter(flist, skip):"," return list(filterfalse(skip.__contains__, flist))","","","# Demonstration and testing.","#","def demo():"," import sys"," import getopt"," options, args = getopt.getopt(sys.argv[1:], 'r')"," if len(args) != 2:"," raise getopt.GetoptError('need exactly two args', None)"," dd = dircmp(args[0], args[1])"," if ('-r', '') in options:"," dd.report_full_closure()"," else:"," dd.report()","","if __name__ == '__main__':"," demo()"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/python/cpython/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"filecmp.py","displayUrl":"https://github.com/python/cpython/blob/b6355d01353d859830502e0e3243b5b81e9e9821/Lib/filecmp.py?raw=true","headerInfo":{"blobSize":"9.95 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":null,"isGitLfs":false,"onBranch":false,"shortPath":"30bd900","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fblob%2Fb6355d01353d859830502e0e3243b5b81e9e9821%2FLib%2Ffilecmp.py","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"313","truncatedSloc":"260"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Python","languageID":303,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/python/cpython/blob/b6355d01353d859830502e0e3243b5b81e9e9821/Lib/filecmp.py","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/python/cpython/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/python/cpython/raw/b6355d01353d859830502e0e3243b5b81e9e9821/Lib/filecmp.py","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":4,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":"/python/.github/blob/5a0a7cb55767fb3667fe2391bcb66bda638edcb4/FUNDING.yml","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"__all__","kind":"constant","ident_start":275,"ident_end":282,"extent_start":275,"extent_end":348,"fully_qualified_name":"__all__","ident_utf16":{"start":{"line_number":17,"utf16_col":0},"end":{"line_number":17,"utf16_col":7}},"extent_utf16":{"start":{"line_number":17,"utf16_col":0},"end":{"line_number":17,"utf16_col":73}}},{"name":"_cache","kind":"constant","ident_start":350,"ident_end":356,"extent_start":350,"extent_end":361,"fully_qualified_name":"_cache","ident_utf16":{"start":{"line_number":19,"utf16_col":0},"end":{"line_number":19,"utf16_col":6}},"extent_utf16":{"start":{"line_number":19,"utf16_col":0},"end":{"line_number":19,"utf16_col":11}}},{"name":"BUFSIZE","kind":"constant","ident_start":362,"ident_end":369,"extent_start":362,"extent_end":378,"fully_qualified_name":"BUFSIZE","ident_utf16":{"start":{"line_number":20,"utf16_col":0},"end":{"line_number":20,"utf16_col":7}},"extent_utf16":{"start":{"line_number":20,"utf16_col":0},"end":{"line_number":20,"utf16_col":16}}},{"name":"DEFAULT_IGNORES","kind":"constant","ident_start":380,"ident_end":395,"extent_start":380,"extent_end":473,"fully_qualified_name":"DEFAULT_IGNORES","ident_utf16":{"start":{"line_number":22,"utf16_col":0},"end":{"line_number":22,"utf16_col":15}},"extent_utf16":{"start":{"line_number":22,"utf16_col":0},"end":{"line_number":23,"utf16_col":73}}},{"name":"clear_cache","kind":"function","ident_start":479,"ident_end":490,"extent_start":475,"extent_end":547,"fully_qualified_name":"clear_cache","ident_utf16":{"start":{"line_number":25,"utf16_col":4},"end":{"line_number":25,"utf16_col":15}},"extent_utf16":{"start":{"line_number":25,"utf16_col":0},"end":{"line_number":27,"utf16_col":18}}},{"name":"cmp","kind":"function","ident_start":553,"ident_end":556,"extent_start":549,"extent_end":1664,"fully_qualified_name":"cmp","ident_utf16":{"start":{"line_number":29,"utf16_col":4},"end":{"line_number":29,"utf16_col":7}},"extent_utf16":{"start":{"line_number":29,"utf16_col":0},"end":{"line_number":67,"utf16_col":18}}},{"name":"_sig","kind":"function","ident_start":1670,"ident_end":1674,"extent_start":1666,"extent_end":1765,"fully_qualified_name":"_sig","ident_utf16":{"start":{"line_number":69,"utf16_col":4},"end":{"line_number":69,"utf16_col":8}},"extent_utf16":{"start":{"line_number":69,"utf16_col":0},"end":{"line_number":72,"utf16_col":24}}},{"name":"_do_cmp","kind":"function","ident_start":1771,"ident_end":1778,"extent_start":1767,"extent_end":2059,"fully_qualified_name":"_do_cmp","ident_utf16":{"start":{"line_number":74,"utf16_col":4},"end":{"line_number":74,"utf16_col":11}},"extent_utf16":{"start":{"line_number":74,"utf16_col":0},"end":{"line_number":83,"utf16_col":27}}},{"name":"dircmp","kind":"class","ident_start":2099,"ident_end":2105,"extent_start":2093,"extent_end":8844,"fully_qualified_name":"dircmp","ident_utf16":{"start":{"line_number":87,"utf16_col":6},"end":{"line_number":87,"utf16_col":12}},"extent_utf16":{"start":{"line_number":87,"utf16_col":0},"end":{"line_number":254,"utf16_col":49}}},{"name":"__init__","kind":"function","ident_start":3581,"ident_end":3589,"extent_start":3577,"extent_end":3941,"fully_qualified_name":"dircmp.__init__","ident_utf16":{"start
44C8
":{"line_number":123,"utf16_col":8},"end":{"line_number":123,"utf16_col":16}},"extent_utf16":{"start":{"line_number":123,"utf16_col":4},"end":{"line_number":133,"utf16_col":32}}},{"name":"phase0","kind":"function","ident_start":3951,"ident_end":3957,"extent_start":3947,"extent_end":4302,"fully_qualified_name":"dircmp.phase0","ident_utf16":{"start":{"line_number":135,"utf16_col":8},"end":{"line_number":135,"utf16_col":14}},"extent_utf16":{"start":{"line_number":135,"utf16_col":4},"end":{"line_number":141,"utf16_col":30}}},{"name":"phase1","kind":"function","ident_start":4312,"ident_end":4318,"extent_start":4308,"extent_end":4743,"fully_qualified_name":"dircmp.phase1","ident_utf16":{"start":{"line_number":143,"utf16_col":8},"end":{"line_number":143,"utf16_col":14}},"extent_utf16":{"start":{"line_number":143,"utf16_col":4},"end":{"line_number":148,"utf16_col":82}}},{"name":"phase2","kind":"function","ident_start":4753,"ident_end":4759,"extent_start":4749,"extent_end":5931,"fully_qualified_name":"dircmp.phase2","ident_utf16":{"start":{"line_number":150,"utf16_col":8},"end":{"line_number":150,"utf16_col":14}},"extent_utf16":{"start":{"line_number":150,"utf16_col":4},"end":{"line_number":183,"utf16_col":43}}},{"name":"phase3","kind":"function","ident_start":5941,"ident_end":5947,"extent_start":5937,"extent_end":6126,"fully_qualified_name":"dircmp.phase3","ident_utf16":{"start":{"line_number":185,"utf16_col":8},"end":{"line_number":185,"utf16_col":14}},"extent_utf16":{"start":{"line_number":185,"utf16_col":4},"end":{"line_number":187,"utf16_col":63}}},{"name":"phase4","kind":"function","ident_start":6136,"ident_end":6142,"extent_start":6132,"extent_end":6689,"fully_qualified_name":"dircmp.phase4","ident_utf16":{"start":{"line_number":189,"utf16_col":8},"end":{"line_number":189,"utf16_col":14}},"extent_utf16":{"start":{"line_number":189,"utf16_col":4},"end":{"line_number":198,"utf16_col":79}}},{"name":"phase4_closure","kind":"function","ident_start":6699,"ident_end":6713,"extent_start":6695,"extent_end":6861,"fully_qualified_name":"dircmp.phase4_closure","ident_utf16":{"start":{"line_number":200,"utf16_col":8},"end":{"line_number":200,"utf16_col":22}},"extent_utf16":{"start":{"line_number":200,"utf16_col":4},"end":{"line_number":203,"utf16_col":31}}},{"name":"report","kind":"function","ident_start":6871,"ident_end":6877,"extent_start":6867,"extent_end":7898,"fully_qualified_name":"dircmp.report","ident_utf16":{"start":{"line_number":205,"utf16_col":8},"end":{"line_number":205,"utf16_col":14}},"extent_utf16":{"start":{"line_number":205,"utf16_col":4},"end":{"line_number":228,"utf16_col":60}}},{"name":"report_partial_closure","kind":"function","ident_start":7908,"ident_end":7930,"extent_start":7904,"extent_end":8083,"fully_qualified_name":"dircmp.report_partial_closure","ident_utf16":{"start":{"line_number":230,"utf16_col":8},"end":{"line_number":230,"utf16_col":30}},"extent_utf16":{"start":{"line_number":230,"utf16_col":4},"end":{"line_number":234,"utf16_col":23}}},{"name":"report_full_closure","kind":"function","ident_start":8093,"ident_end":8112,"extent_start":8089,"extent_end":8280,"fully_qualified_name":"dircmp.report_full_closure","ident_utf16":{"start":{"line_number":236,"utf16_col":8},"end":{"line_number":236,"utf16_col":27}},"extent_utf16":{"start":{"line_number":236,"utf16_col":4},"end":{"line_number":240,"utf16_col":36}}},{"name":"methodmap","kind":"constant","ident_start":8286,"ident_end":8295,"extent_start":8286,"extent_end":8611,"fully_qualified_name":"dircmp.methodmap","ident_utf16":{"start":{"line_number":242,"utf16_col":4},"end":{"line_number":242,"utf16_col":13}},"extent_utf16":{"start":{"line_number":242,"utf16_col":4},"end":{"line_number":246,"utf16_col":57}}},{"name":"__getattr__","kind":"function","ident_start":8621,"ident_end":8632,"extent_start":8617,"extent_end":8793,"fully_qualified_name":"dircmp.__getattr__","ident_utf16":{"start":{"line_number":248,"utf16_col":8},"end":{"line_number":248,"utf16_col":19}},"extent_utf16":{"start":{"line_number":248,"utf16_col":4},"end":{"line_number":252,"utf16_col":34}}},{"name":"__class_getitem__","kind":"constant","ident_start":8799,"ident_end":8816,"extent_start":8799,"extent_end":8844,"fully_qualified_name":"dircmp.__class_getitem__","ident_utf16":{"start":{"line_number":254,"utf16_col":4},"end":{"line_number":254,"utf16_col":21}},"extent_utf16":{"start":{"line_number":254,"utf16_col":4},"end":{"line_number":254,"utf16_col":49}}},{"name":"cmpfiles","kind":"function","ident_start":8851,"ident_end":8859,"extent_start":8847,"extent_end":9416,"fully_qualified_name":"cmpfiles","ident_utf16":{"start":{"line_number":257,"utf16_col":4},"end":{"line_number":257,"utf16_col":12}},"extent_utf16":{"start":{"line_number":257,"utf16_col":0},"end":{"line_number":275,"utf16_col":14}}},{"name":"_cmp","kind":"function","ident_start":9545,"ident_end":9549,"extent_start":9541,"extent_end":9662,"fully_qualified_name":"_cmp","ident_utf16":{"start":{"line_number":284,"utf16_col":4},"end":{"line_number":284,"utf16_col":8}},"extent_utf16":{"start":{"line_number":284,"utf16_col":0},"end":{"line_number":288,"utf16_col":16}}},{"name":"_filter","kind":"function","ident_start":9726,"ident_end":9733,"extent_start":9722,"extent_end":9802,"fully_qualified_name":"_filter","ident_utf16":{"start":{"line_number":293,"utf16_col":4},"end":{"line_number":293,"utf16_col":11}},"extent_utf16":{"start":{"line_number":293,"utf16_col":0},"end":{"line_number":294,"utf16_col":54}}},{"name":"demo","kind":"function","ident_start":9840,"ident_end":9844,"extent_start":9836,"extent_end":10147,"fully_qualified_name":"demo","ident_utf16":{"start":{"line_number":299,"utf16_col":4},"end":{"line_number":299,"utf16_col":8}},"extent_utf16":{"start":{"line_number":299,"utf16_col":0},"end":{"line_number":309,"utf16_col":19}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/python/cpython/branches":{"post":"Y6qG8aBmtDmf5Mc-jm8NoasE3tKeSjjht61mtVaVwh-D_7nQOq0VTuYGxgpL5Q_KXWMwkCxs939Yp6YI4aBssA"},"/repos/preferences":{"post":"9s01sBW_yj84B6qeG6cxgGrni5VxgM2KY-ECSom5C8Wlo6dzdLXo1B48yj8WE2flxGTPIqFUjpjC8oiZabj5Mw"}}},"title":"cpython/Lib/filecmp.py at b6355d01353d859830502e0e3243b5b81e9e9821 · python/cpython","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}