def walk_lockstep(self, down_loc, dest_parent): if down_loc != self.fname: raise ValueError(down_loc, self.fname) dest_loc = os.path.join(dest_parent, unix_basename(down_loc)) for (dirpath, dirnames, filenames) in os.walk(down_loc): if dirpath == down_loc: d2 = dest_loc else: d2 = os.path.join(dest_loc, os.path.relpath(dirpath, down_loc)) # Happens when transitioning from shallow symlinks, # maybe we should error out anyway. if os.path.lexists(d2): if not os.path.isdir(d2): LOGGER.warn('%s already exists and isn\'t a directory', d2) # Prevent recursion dirnames[:] = [] continue else: os.mkdir(d2) for fname in filenames: src = os.path.join(dirpath, fname) dest = os.path.join(d2, fname) yield src, dest
def __init__(self, fname, name=None): self.fname = fname if name is None: self.name = unix_basename(fname) else: self.name = name