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.

Function Summary
  compareContents(path1, path2, verbose)
Compares the contents of two directories to see if they are equivalent.
  normalizeDir(path)
Normalizes a directory name.

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

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 path12 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.

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 0x3ae0f0ac>                                

Generated by Epydoc 2.1 on Mon Sep 4 13:49:32 2006 http://epydoc.sf.net