def localize(self, local): """ The parameters are a local with virtual roots. Return a path constructed with the first value in the specified local's roots that match the root name and the path. """ roots = local.getVirtualRoots() if self._root in roots: return fileutils.joinPath(roots[self._root], self._path) raise errors.VirtualPathError("Cannot localize virtual path '%s', " " virtual root not found for this local" % self)
def __init__(self, profCtx, targStore): base.BaseStoreContext.__init__(self, profCtx, targStore) self._variables.addVar("targetName", self.name) subdir = self.store.subdir or "" subdir = fileutils.str2path(subdir) subdir = fileutils.ensureRelDirPath(subdir) subdir = fileutils.cleanupPath(subdir) self._variables.addVar("targetSubdir", subdir) targPath = (fileutils.joinPath(self._variables["sourceDir"], subdir) + self._variables["sourceFile"]) self._variables.addFileVars(fileutils.ensureRelPath(targPath), "target", extension=self.extension)
def append(self, *parts): goodparts = [p for p in parts if p] if not goodparts: return self path = fileutils.joinPath(self._path, fileutils.joinPath(*goodparts)) return VirtualPath(path, self._root)
def join(self, virtPath): #FIXME: Maybe better to raise an exception assert virtPath._root == self._root return VirtualPath(fileutils.joinPath(self._path, virtPath._path), self._root)