making testbackup.py work
authorEduardo Robles Elvira <edulix@wadobo.com>
Wed, 19 Mar 2014 12:16:29 +0000 (13:16 +0100)
committerEduardo Robles Elvira <edulix@wadobo.com>
Wed, 19 Mar 2014 12:16:29 +0000 (13:16 +0100)
deltatar/deltatar.py

index e01ccf6..2c1ded7 100644 (file)
@@ -359,7 +359,7 @@ class DeltaTar(object):
 
         return match
 
-    def _recursive_walk_dir(self, source_path):
+    def _recursive_walk_dir(self, source_path, strip_base_dir = False):
         '''
         Walk a directory recursively, yielding each file/directory
         '''
@@ -380,6 +380,10 @@ class DeltaTar(object):
 
         queue = [source_path]
 
+        if strip_base_dir:
+            beginging_size = len(source_path)
+        else:
+            beginging_size = 0
         while queue:
             cur_path = queue.pop(0)
 
@@ -392,7 +396,7 @@ class DeltaTar(object):
                 status = self.filter_path(child, source_path, is_dir)
 
                 if status == MATCH:
-                    yield child
+                    yield child[beginging_size:]
 
                 if is_dir and (status == MATCH or status == PARENT_MATCH):
                     queue.append(child)
@@ -1046,11 +1050,11 @@ class DeltaTar(object):
             try:
                 path = iter.__next__()
                 if strip == 0:
-                    yield self._stat_dict(path)
+                    yield self._stat_dict(path), 0
                 else:
                     st = self._stat_dict(path)
                     st['path'] = "/".join(path.split("/")[strip:])
-                    yield st
+                    yield st, 0
             except StopIteration:
                 break