Package CedarBackup2 :: Module filesystem
[show private | hide private]
[frames | no frames]

Module CedarBackup2.filesystem

Provides filesystem-related objects.

Author: Kenneth J. Pronovici <pronovic@ieee.org>

Classes
FilesystemList Represents a list of filesystem items.
BackupFileList List of files to be backed up.
PurgeItemList List of files and directories to be purged.
SpanItem Item returned by BackupFileList.generateSpan.

Function Summary
  compareContents(path1, path2, verbose)
Compares the contents of two directories to see if they are equivalent.
  compareDigestMaps(digest1, digest2, verbose)
Compares two digest maps and throws an exception if they differ.
  normalizeDir(path)
Normalizes a directory name.

Variable Summary
Logger logger = <logging.Logger instance at 0x403643ac>

Function Details

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.

compareDigestMaps(digest1, digest2, verbose=False)

Compares two digest maps and throws an exception if they differ.
Parameters:
digest1 - First digest to compare.
           (type=Digest as returned from BackupFileList.generateDigestMap())
digest2 - Second digest to compare.
           (type=Digest as returned from BackupFileList.generateDigestMap())
verbose - Indicates whether a verbose response should be given.
           (type=Boolean)
Raises:
ValueError - If the two directories are not equivalent.

normalizeDir(path)

Normalizes a directory name.

For our purposes, a directory name is normalized by removing the trailing path separator, if any. This is important because we want directories to appear within lists in a consistent way, although from the user's perspective passing in /path/to/dir/ and /path/to/dir are equivalent.
Parameters:
path - Path to be normalized.
           (type=String representing a path on disk)
Returns:
Normalized path, which should be equivalent to the original.

Variable Details

logger

Type:
Logger
Value:
<logging.Logger instance at 0x403643ac>                                

Generated by Epydoc 2.1 on Thu Mar 29 20:58:30 2007 http://epydoc.sf.net