author |
<albertogli@telpin.com.ar> 2005-03-06 16:46:49 UTC |
committer |
<albertogli@telpin.com.ar> 2005-03-06 16:46:49 UTC |
parent | 674487a67fcc770f0436c30bb9355f56586b1d65 |
abk | +21 | -12 |
diff --git a/abk b/abk index ce54772..b9c2c56 100644 --- a/abk +++ b/abk @@ -340,17 +340,17 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): src_path = src # load destination index - if verbose: print "* loading destination index" + printv("* loading destination index") dstidx = index_file(dstidx_path) dstidx.load() # create source index - if verbose: print "* building source index" + printv("* building source index") srcidx = index_file(srcidx_path) srcidx.populate(src_path) srcidx.save() - if verbose: print "* sync" + printv("* sync") # compare them update_files = [] @@ -360,7 +360,7 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): # files missing in destination, or data changed #dst = os.path.join(dst_path, f) dst = dst_path + '/' + f - if verbose: print 'data\t', f, dst + printv('data\t', f, dst) quiet_unlink(dst) srcidx.db[f].copy_file(dst) update_files.append((f, dst)) @@ -368,14 +368,14 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): # metadata changed #dst = os.path.join(dst_path, f) dst = dst_path + '/' + f - if verbose: print 'mdata\t', f, dst + printv('mdata\t', f, dst) update_files.append((f, dst)) # metadata gets changed later because otherwise we could leave # directory times wrong due to files being added to a directory after # their creation; this way we're sure there will be no more file # creation afterwards - if verbose: print '* mdata' + printv('* mdata') for f, dst in update_files: try: srcidx.db[f].update_mdata(dst) @@ -386,27 +386,27 @@ def make_sync(src_path, srcidx_path, dst_path, dstidx_path): # back together pass - if verbose: print '* unlink' + printv('* unlink') for f in dstidx.names: if f not in srcidx.names: # files in destination and not in source #dst = os.path.join(dst_path, f) dst = dst_path + '/' + f - if verbose: print 'unlink\t', f, dst + printv('unlink\t', f, dst) force_unlink(dst, dstidx.db[f].type) def show_idx(idx_path): - if verbose: print "* loading index" + printv("* loading index") idx = index_file(idx_path) idx.load() for f in idx.names: fi = idx.db[f] - if verbose: print "%s %d %f %s %s" % (fi.type, fi.size, fi.mtime, - str(fi.hash), fi.name) + printv( "%s %d %f %s %s" % (fi.type, fi.size, fi.mtime, + str(fi.hash), fi.name) ) def build_idx(idx_path, path): - if verbose: print "* building index" + printv("* building index") # see comments in make_sync() while path[-1] == '/' and path != '/': @@ -428,6 +428,15 @@ def build_idx(idx_path, path): # helper functions # +def printv(*params): + "Equivalent to 'if verbose: print params'." + if not verbose: + return + for i in params: + print i, + print + + def parse_options(): "Commandline options parser." from optparse import OptionParser