[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:
Candice Bentéjac 2025-01-08 18:20:59 +01:00
parent 40fd46d476
commit 6cbb97d9a8
2 changed files with 15 additions and 4 deletions

View file

@ -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):