def addFileVars(self, filePath, kind, extension=None): """ Add the diffrent parts of the file to the substitution set like following: The extension can be specified explicitly to support multi-dot extensions. In this case the extension is not extracted from the file path. Parameters: filePath: /my.sub/folder/file.name.ext kind: "input" Added vars: "inputPath" (str): "/my.sub/folder/file.name.ext", "inputFile" (str): "file.name.ext", "inputBasename" (str): "file.name", "inputExtension" (str): ".ext", "inputDir" (str): "/my.sub/folder/" """ path, file, ext = fileutils.splitPath(filePath, extension == None) if extension: ext = extension self._variables[kind + "Path"] = filePath + extension else: self._variables[kind + "Path"] = filePath self._variables[kind + "File"] = file + ext self._variables[kind + "Extension"] = ext self._variables[kind + "Basename"] = file self._variables[kind + "Dir"] = path
def __get__(self, obj, type=None): relPath = getattr(obj, self._relPropertyName) file, ext = fileutils.splitPath(relPath)[1:3] return file + ext
def __get__(self, obj, type=None): baseDir = getattr(obj, self._basePropertyName) relPath = getattr(obj, self._relPropertyName) path, file = fileutils.splitPath(relPath)[:2] return baseDir.append(path)
def __applyFileTemplate(tmpl, path): if not tmpl: return path p, b, e = fileutils.splitPath(path) vars = {"path": p, "basename": b, "extension": e, "filename": (b + e)} format = utils.filterFormat(tmpl, vars) return format % vars