diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-05-10 23:14:35 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-05-10 23:14:35 +0000 |
commit | 807241bc4f322edc6f95782291900362484263df (patch) | |
tree | 95dc93d87081ab901e31844867d4facca6207aac /rdiff-backup/rdiff_backup/selection.py | |
parent | 5c059e737511644b0056b8326b52763c82efcac4 (diff) | |
download | rdiff-backup-807241bc4f322edc6f95782291900362484263df.tar.gz |
Lots of changes, see changelog for 0.7.4.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@72 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/selection.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/selection.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py index aaa8639..cae6db3 100644 --- a/rdiff-backup/rdiff_backup/selection.py +++ b/rdiff-backup/rdiff_backup/selection.py @@ -60,21 +60,20 @@ class Select: # This re should not match normal filenames, but usually just globs glob_re = re.compile("(.*[*?[]|ignorecase\\:)", re.I | re.S) - def __init__(self, rpath, source): - """DSRPIterator initializer. + def __init__(self, dsrpath, quoted_filenames = None): + """DSRPIterator initializer. dsrp is the root directory - rpath is the root dir. Source is true if rpath is the root of - the source directory, and false for the mirror directory + When files have quoted characters in them, quoted_filenames + should be true. Then RPath's index will be the unquoted + version. """ - assert isinstance(rpath, RPath) + assert isinstance(dsrpath, DSRPath) self.selection_functions = [] - self.source = source - if isinstance(rpath, DSRPath): self.dsrpath = rpath - else: self.dsrpath = DSRPath(rpath.conn, rpath.base, - rpath.index, rpath.data) + self.dsrpath = dsrpath self.prefix = self.dsrpath.path - + self.quoting_on = Globals.quoting_enabled and quoted_filenames + def set_iter(self, starting_index = None, sel_func = None): """Initialize more variables, get ready to iterate @@ -106,7 +105,7 @@ class Select: """ s = sel_func(dsrpath) - if s === 0: return + if s == 0: return elif s == 1: # File is included yield dsrpath if dsrpath.isdir(): @@ -122,11 +121,15 @@ class Select: def iterate_in_dir(self, dsrpath, rec_func, sel_func): """Iterate the dsrps in directory dsrpath.""" - dir_listing = dsrpath.listdir() - dir_listing.sort() - for filename in dir_listing: - for dsrp in rec_func(dsrpath.append(filename), rec_func, sel_func): - yield dsrp + if self.quoting_on: + for subdir in FilenameMapping.get_quoted_dir_children(dsrpath): + for dsrp in rec_func(subdir, rec_func, sel_func): yield dsrp + else: + dir_listing = dsrpath.listdir() + dir_listing.sort() + for filename in dir_listing: + for dsrp in rec_func(dsrpath.append(filename), + rec_func, sel_func): yield dsrp def iterate_starting_from(self, dsrpath, rec_func, sel_func): """Like Iterate, but only yield indicies > self.starting_index""" |