def _resolve_paths(self, src_root_node, use_destdir): variables = copy.copy(self._path_variables) variables.update(self._variables) variables['_srcrootdir'] = src_root_node.abspath() root = find_root(src_root_node) def _prefix_destdir(path): destdir = subst_vars("$destdir", variables) if path: tail = explode_path(path)[1:] if not tail: raise ValueError("Invalid target directory in section %r " "(not absolute: %r)" % (name, path)) return os.path.join(destdir, os.path.join(*tail)) else: raise ValueError("Invalid target directory in section " "%r: %r" % (name, path)) node_sections = {} for category in self.files: node_sections[category] = {} for name, section in self.files[category].items(): srcdir = subst_vars(section.source_dir, variables) target = subst_vars(section.target_dir, variables) if use_destdir: target = _prefix_destdir(target) srcdir_node = root.find_node(srcdir) if srcdir_node is None: raise IOError("directory %r not found !" % (srcdir,)) target_node = root.make_node(target) node_sections[category][name] = \ [(srcdir_node.find_node(f), target_node.make_node(g)) for f, g in section.files] return node_sections
def test_root(self): self.assertEqual(self.root, find_root(self.root))