Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module filesystem :: Class FilesystemList |
|
object
--+ |list
--+ | FilesystemList
BackupFileList
,
PurgeItemList
Represents a list of filesystem items.
This is a generic class that represents a list of filesystem items. Callers can add individual files or directories to the list, or can recursively add the contents of a directory. The class also allows for up-front exclusions in several forms (all files, all directories, all items matching a pattern, or all directories containing a specific "ignore file"). Symbolic links are typically backed up non-recursively, i.e. the link to a directory is backed up, but not the contents of that link (we don't want to deal with recursive loops, etc.).
The custom methods such as addFile
will only add items if they exist
on the filesystem and do not match any exclusions that are already in
place. However, since a FilesystemList is a subclass of Python's standard
list class, callers can also add items to the list in the usual way,
using methods like append()
or insert()
. No
validations apply to items added to the list in this way; however, many
list-manipulation methods deal "gracefully" with items that
don't exist in the filesystem, often by ignoring them.
pop()
or
remove()
or they can use custom methods to remove specific
types of entries or entries which match a particular pattern.
Notes:
^
and end with
$
.
Method Summary | |
---|---|
Initializes a list with no configured exclusions. | |
Adds a file to the list. | |
Adds a directory to the list. | |
Adds the contents of a directory to the list. | |
Removes file entries from the list. | |
Removes directory entries from the list. | |
Removes soft link entries from the list. | |
Removes from the list all entries matching a pattern. | |
Removes from the list all entries that do not exist on disk. | |
Normalizes the list, ensuring that each entry is unique. | |
Verifies that all entries in the list exist on disk. | |
Inherited from list | |
x.__add__(y) <==> x+y | |
x.__contains__(y) <==> y in x | |
x.__delitem__(y) <==> del x[y] | |
Use of negative indices is not supported. | |
x.__eq__(y) <==> x==y | |
x.__ge__(y) <==> x>=y | |
x.__getattribute__('name') <==> x.name | |
x.__getitem__(y) <==> x[y] | |
Use of negative indices is not supported. | |
x.__gt__(y) <==> x>y | |
x.__hash__() <==> hash(x) | |
x.__iadd__(y) <==> x+=y | |
x.__imul__(y) <==> x*=y | |
x.__iter__() <==> iter(x) | |
x.__le__(y) <==> x<=y | |
x.__len__() <==> len(x) | |
x.__lt__(y) <==> x<y | |
x.__mul__(n) <==> x*n | |
x.__ne__(y) <==> x!=y | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
x.__repr__() <==> repr(x) | |
L.__reversed__() -- return a reverse iterator over the list | |
x.__rmul__(n) <==> n*x | |
x.__setitem__(i, y) <==> x[i]=y | |
Use of negative indices is not supported. | |
L.append(object) -- append object to end | |
L.count(value) -> integer -- return number of occurrences of value | |
L.extend(iterable) -- extend list by appending elements from the iterable | |
L.index(value, [start, [stop]]) -> integer -- return first index of value | |
L.insert(index, object) -- insert object before index | |
L.pop([index]) -> item -- remove and return item at index (default last) | |
L.remove(value) -- remove first occurrence of value | |
L.reverse() -- reverse *IN PLACE* | |
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Property Summary | |
---|---|
excludeFiles : Boolean indicating whether files should be excluded. | |
excludeDirs : Boolean indicating whether directories should be excluded. | |
excludeLinks : Boolean indicating whether soft links should be excluded. | |
excludePaths : List of absolute paths to be excluded. | |
excludePatterns : List of regular expression patterns to be excluded. | |
ignoreFile : Name of file which will cause directory contents to be ignored. |
Method Details |
---|
__init__(self)
Initializes a list with no configured exclusions.
|
addFile(self, path)Adds a file to the list. The path must exist and must be a file or a link to an existing file. It will be added to the list subject to any exclusions that are in place.
|
addDir(self, path)Adds a directory to the list. The path must exist and must be a directory or a link to an existing directory. It will be added to the list subject to any exclusions that are in place. TheignoreFile does not apply to this method,
only to addDirContents .
|
addDirContents(self, path, recursive=True)Adds the contents of a directory to the list. The path must exist and must be a directory or a link to a directory. The contents of the directory (as well as the directory path itself) will be recursively added to the list, subject to any exclusions that are in place. If you only want the directory and its immediate contents to be added, then pass inrecursive=False .
|
removeFiles(self, pattern=None)Removes file entries from the list. If excludeFiles to True before
adding items to the list.
|
removeDirs(self, pattern=None)Removes directory entries from the list. If excludeDirs to True before
adding items to the list (note that this will not prevent you from
recursively adding the contents of directories).
|
removeLinks(self, pattern=None)Removes soft link entries from the list. If excludeLinks to True before
adding items to the list.
|
removeMatch(self, pattern)Removes from the list all entries matching a pattern. This method removes from the list all entries which match the passed inpattern . Since there is no need to check the type of
each entry, it is faster to call this method than to call the removeFiles , removeDirs or removeLinks methods individually. If you
know which patterns you will want to remove ahead of time, you may be
better off setting excludePatterns before adding items to
the list.
|
removeInvalid(self)Removes from the list all entries that do not exist on disk. This method removes from the list all entries which do not currently exist on disk in some form. No attention is paid to whether the entries are files or directories.
|
normalize(self)Normalizes the list, ensuring that each entry is unique. |
verify(self)Verifies that all entries in the list exist on disk.
|
Property Details |
---|
excludeFilesBoolean indicating whether files should be excluded. |
excludeDirsBoolean indicating whether directories should be excluded. |
excludeLinksBoolean indicating whether soft links should be excluded. |
excludePathsList of absolute paths to be excluded. |
excludePatternsList of regular expression patterns to be excluded. |
ignoreFileName of file which will cause directory contents to be ignored. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Dec 18 22:53:29 2006 | http://epydoc.sf.net |