mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 18:27:23 +02:00
[core] Add default relative paths to the command line variables
Add 2 default entries to the command line variables: - `nodeCacheFolder`, which contains the location of the cache folder - `nodeSourceCodeFolder`, which contains the location of the file describing the node
This commit is contained in:
parent
40fd46d476
commit
6cbb97d9a8
2 changed files with 15 additions and 4 deletions
|
@ -362,7 +362,14 @@ class Attribute(BaseObject):
|
|||
Return the value. If it is a string, expressions will be evaluated.
|
||||
'''
|
||||
if isinstance(self.value, str):
|
||||
return Template(self.value).safe_substitute(os.environ)
|
||||
substituted = Template(self.value).safe_substitute(os.environ)
|
||||
try:
|
||||
varResolved = substituted.format(**self.node._cmdVars)
|
||||
return varResolved
|
||||
except (KeyError, IndexError):
|
||||
# Catch KeyErrors and IndexErros to be able to open files created prior to the support of
|
||||
# relative variables (when self.node._cmdVars was not used to evaluate expressions in the attribute)
|
||||
return substituted
|
||||
return self.value
|
||||
|
||||
def getValueStr(self, withQuotes=True):
|
||||
|
|
|
@ -758,6 +758,8 @@ class BaseNode(BaseObject):
|
|||
|
||||
""" Generate command variables using input attributes and resolved output attributes names and values. """
|
||||
self._cmdVars["uid"] = self._uid
|
||||
self._cmdVars["nodeCacheFolder"] = self.internalFolder
|
||||
self._cmdVars["nodeSourceCodeFolder"] = self.sourceCodeFolder
|
||||
|
||||
# Evaluate input params
|
||||
for name, attr in self._attributes.objects.items():
|
||||
|
@ -1022,8 +1024,10 @@ class BaseNode(BaseObject):
|
|||
|
||||
# Update command variables / output attributes
|
||||
self._cmdVars = {
|
||||
'cache': cacheDir or self.graph.cacheDir,
|
||||
'nodeType': self.nodeType,
|
||||
"cache": cacheDir or self.graph.cacheDir,
|
||||
"nodeType": self.nodeType,
|
||||
"nodeCacheFolder": self._internalFolder,
|
||||
"nodeSourceCodeFolder": self.sourceCodeFolder
|
||||
}
|
||||
self._computeUid()
|
||||
self._buildCmdVars()
|
||||
|
@ -1445,7 +1449,7 @@ class Node(BaseNode):
|
|||
|
||||
self.packageName = self.nodeDesc.packageName
|
||||
self.packageVersion = self.nodeDesc.packageVersion
|
||||
self._internalFolder = self.nodeDesc.internalFolder
|
||||
self._internalFolder = "{cache}/{nodeType}/{uid}"
|
||||
self._sourceCodeFolder = self.nodeDesc.sourceCodeFolder
|
||||
|
||||
for attrDesc in self.nodeDesc.inputs:
|
||||
|
|
Loading…
Add table
Reference in a new issue