compareContents(path1,
path2,
verbose=False)
Compares the contents of two directories to see if they are
equivalent.
The two directories are recursively compared. First, we check
whether they contain exactly the same set of files. Then, we check to
see every given file has exactly the same contents in both
directories.
This is all relatively simple to implement through the magic of BackupFileList.generateDigestMap , which
knows how to strip a path prefix off the front of each entry in the
mapping it generates. This makes our comparison as simple as creating a
list for each path, then generating a digest map for each path and
comparing the two.
If no exception is thrown, the two directories are considered
identical.
If the verbose flag is True , then an
alternate (but slower) method is used so that any thrown exception can
indicate exactly which file caused the comparison to fail. The thrown
ValueError exception distinguishes between the directories
containing different files, and containing the same files with
differing content.
-
- Parameters:
path1 -
First path to compare.
(type=String representing a path on disk)
path2 -
First path to compare.
(type=String representing a path on disk)
verbose -
Indicates whether a verbose response should be given.
(type=Boolean)
- Raises:
ValueError -
If a directory doesn't exist or can't be read.
ValueError -
If the two directories are not equivalent.
IOError -
If there is an unusual problem reading the directories.
|