💾 Archived View for tris.fyi › pydoc › filecmp captured on 2023-01-29 at 03:13:36. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-07-16)

🚧 View Differences

-=-=-=-=-=-=-

Back to module index

Go to module by name

filecmp

Utilities for comparing files and directories.

Classes:
    dircmp

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


Classes

GenericAlias

Represent a PEP 585 generic type

E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).

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() -> 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.
     
phase0(self)
phase1(self)
phase2(self)
phase3(self)
phase4(self)
phase4_closure(self)
report(self)
report_full_closure(self)
report_partial_closure(self)
methodmap = {'subdirs': <function dircmp.phase4 at 0x7f75e11c4ca0>, 'same_files': <function dircmp.phase3 at 0x7f75e11c4c10>, 'diff_files': <function dircmp.phase3 at 0x7f75e11c4c10>, 'funny_files': <function dircmp.phase3 at 0x7f75e11c4c10>, 'common_dirs': <function dircmp.phase2 at 0x7f75e11c4b80>, 'common_files': <function dircmp.phase2 at 0x7f75e11c4b80>, 'common_funny': <function dircmp.phase2 at 0x7f75e11c4b80>, 'common': <function dircmp.phase1 at 0x7f75e11c4af0>, 'left_only': <function dircmp.phase1 at 0x7f75e11c4af0>, 'right_only': <function dircmp.phase1 at 0x7f75e11c4af0>, 'left_list': <function dircmp.phase0 at 0x7f75e11c4a60>, 'right_list': <function dircmp.phase0 at 0x7f75e11c4a60>}

filterfalse

Return those items of iterable for which function(item) is false.

If function is None, return the items that are false.

Functions

clear_cache

clear_cache()

  Clear the filecmp cache.

cmp

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().

    

cmpfiles

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.

    

demo

demo()

Other members

BUFSIZE = 8192
DEFAULT_IGNORES = ['RCS', 'CVS', 'tags', '.git', '.hg', '.bzr', '_darcs', '__pycache__']

Modules

os

stat