def _strip_unreferenced_directories(entries): """Strip all directories that don't (in)directly contain any files. :param entries: List of path strings or (path, ie) tuples to process """ directories = [] for entry in entries: if isinstance(entry, basestring): path = entry else: path = entry[0] if not path or path[-1] == "/": # directory directories.append((path, entry)) else: # Yield the referenced parent directories for dirpath, direntry in directories: if osutils.is_inside(dirpath, path): yield direntry directories = [] yield entry
def _ensure_in_jail(self, test_case, path): jail_root = self._get_jail_root(test_case) if not osutils.is_inside(jail_root, osutils.normalizepath(path)): raise ValueError('%s is not inside %s' % (path, jail_root))