def wrapper(*args, **kwargs): import shutil import glob dst = self.dst if "__tmp__" in dst: dst = dst.replace('__tmp__', 'tmp/%s/' % util.find_test_name().replace(':', '_')) src = self.src if isinstance(src, basestring): src = [self.src] files = [] for pattern in src: files.extend(glob.glob(pattern)) if len(src) > 1 or set(files) != set(src): # Glob expansion, "dst" is a prefix pairs = [(i, dst + i) for i in files] else: # Explicit source and destination names pairs = [(self.src, dst)] for src, dst in pairs: log.trace("Copying %r to %r" % (src, dst)) shutil.copy(src, dst) try: return func(*args, **kwargs) finally: for _, dst in pairs: if os.path.exists(dst): log.trace("Removing %r" % dst) os.remove(dst)
def wrapper(*args, **kwargs): import shutil import glob dst = self.dst if "__tmp__" in dst: dst = dst.replace( '__tmp__', 'tmp/%s/' % util.find_test_name().replace(':', '_')) src = self.src if isinstance(src, basestring): src = [self.src] files = [] for pattern in src: files.extend(glob.glob(pattern)) if len(src) > 1 or set(files) != set(src): # Glob expansion, "dst" is a prefix pairs = [(i, dst + i) for i in files] else: # Explicit source and destination names pairs = [(self.src, dst)] for src, dst in pairs: log.trace("Copying %r to %r" % (src, dst)) shutil.copy(src, dst) try: return func(*args, **kwargs) finally: for _, dst in pairs: if os.path.exists(dst): log.trace("Removing %r" % dst) os.remove(dst)