]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/scripts/tahoe_cp.py
tahoe_cp: minor cleanups, no behavior changes
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / scripts / tahoe_cp.py
index 850a1b37df0470bdd1538016305e1daa8cf6c1c1..3089239275cc67899781d60afb1e27045183079c 100644 (file)
@@ -116,7 +116,7 @@ class LocalDirectorySource:
                 child = LocalDirectorySource(self.progressfunc, pn, n)
                 self.children[n] = child
                 if recurse:
-                    child.populate(True)
+                    child.populate(recurse=True)
             elif os.path.isfile(pn):
                 self.children[n] = LocalFileSource(pn, n)
             else:
@@ -144,7 +144,7 @@ class LocalDirectoryTarget:
                 child = LocalDirectoryTarget(self.progressfunc, pn)
                 self.children[n] = child
                 if recurse:
-                    child.populate(True)
+                    child.populate(recurse=True)
             else:
                 assert os.path.isfile(pn)
                 self.children[n] = LocalFileTarget(pn)
@@ -152,7 +152,7 @@ class LocalDirectoryTarget:
     def get_child_target(self, name):
         precondition(isinstance(name, unicode), name)
         if self.children is None:
-            self.populate(False)
+            self.populate(recurse=False)
         if name in self.children:
             return self.children[name]
         pathname = os.path.join(self.pathname, name)
@@ -280,7 +280,7 @@ class TahoeDirectorySource:
                     if readcap:
                         self.cache[readcap] = child
                     if recurse:
-                        child.populate(True)
+                        child.populate(recurse=True)
                 self.children[name] = child
             else:
                 # TODO: there should be an option to skip unknown nodes.
@@ -380,7 +380,7 @@ class TahoeDirectoryTarget:
                     if readcap:
                         self.cache[readcap] = child
                     if recurse:
-                        child.populate(True)
+                        child.populate(recurse=True)
                 self.children[name] = child
             else:
                 # TODO: there should be an option to skip unknown nodes.
@@ -392,7 +392,7 @@ class TahoeDirectoryTarget:
         # return a new target for a named subdirectory of this dir
         precondition(isinstance(name, unicode), name)
         if self.children is None:
-            self.populate(False)
+            self.populate(recurse=False)
         if name in self.children:
             return self.children[name]
         writecap = make_tahoe_subdirectory(self.nodeurl, self.writecap, name)
@@ -409,7 +409,7 @@ class TahoeDirectoryTarget:
             inf = inf.read()
 
         if self.children is None:
-            self.populate(False)
+            self.populate(recurse=False)
 
         # Check to see if we already have a mutable file by this name.
         # If so, overwrite that file in place.
@@ -531,7 +531,7 @@ class Copier:
                 target_is_file = False
 
         if target_is_file and target_has_trailing_slash:
-            self.to_stderr("target is not a directory, but has a slash")
+            self.to_stderr("target is not a directory, but ends with a slash")
             return 1
 
         if len(sources) > 1 and target_is_file:
@@ -702,12 +702,12 @@ class Copier:
     def copy_things_to_directory(self, sources, target):
         # step one: if the target is missing, we should mkdir it
         target = self.maybe_create_target(target)
-        target.populate(False)
+        target.populate(recurse=False)
 
         # step two: scan any source dirs, recursively, to find children
         for s in sources:
             if isinstance(s, DirectorySources):
-                s.populate(True)
+                s.populate(recurse=True)
             if isinstance(s, FileSources):
                 # each source must have a name, or be a directory
                 _assert(s.basename() is not None, s)
@@ -778,7 +778,7 @@ class Copier:
                 subtarget = target.get_child_target(name)
                 self.assign_targets(targetmap, child, subtarget)
             else:
-                precondition(isinstance(child, FileSources), child)
+                _assert(isinstance(child, FileSources), child)
                 targetmap[target].append(child)
 
     def copy_to_targetmap(self, targetmap):
@@ -789,9 +789,9 @@ class Copier:
         targets_finished = 0
 
         for target, sources in targetmap.items():
-            precondition(isinstance(target, DirectoryTargets), target)
+            _assert(isinstance(target, DirectoryTargets), target)
             for source in sources:
-                precondition(isinstance(source, FileSources), source)
+                _assert(isinstance(source, FileSources), source)
                 self.copy_file_into_dir(source, source.basename(), target)
                 files_copied += 1
                 self.progress("%d/%d files, %d/%d directories" %
@@ -803,8 +803,7 @@ class Copier:
                           (targets_finished, len(targetmap)))
 
     def count_files_to_copy(self, targetmap):
-        files_to_copy = sum([len(sources) for sources in targetmap.values()])
-        return files_to_copy
+        return sum([len(sources) for sources in targetmap.values()])
 
     def copy_file_into_dir(self, source, name, target):
         precondition(isinstance(source, FileSources), source)