|
|
|
@ -3676,14 +3676,24 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
and funcName in [x.split('.')[0] for x in
|
|
|
|
|
os.listdir(pathJoin(dirPath, 'scripts/functions/'))]]
|
|
|
|
|
if customFunc:
|
|
|
|
|
primeTemp = customFunc[-1]
|
|
|
|
|
funArgv = funcEnd.rpartition(")")[0]
|
|
|
|
|
execName = [x for x in os.listdir(pathJoin(primeTemp, 'scripts/functions/')) if x.split('.')[0] == funcName][0]
|
|
|
|
|
textTemplateTmp = subprocess.check_output([pathJoin(primeTemp, 'scripts/functions/', execName), funArgv], encoding='UTF-8')
|
|
|
|
|
if textTemplateTmp is not None:
|
|
|
|
|
try:
|
|
|
|
|
primeTemp = customFunc[-1]
|
|
|
|
|
funArgv = funcEnd.rpartition(")")[0].split(',')
|
|
|
|
|
execName = [x for x in os.listdir(pathJoin(primeTemp, 'scripts/functions/')) if x.split('.')[0] == funcName][0]
|
|
|
|
|
funcRes = subprocess.check_output([pathJoin(primeTemp, 'scripts/functions/', execName), ' '.join(funArgv)], encoding='UTF-8').strip()
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, funcRes)
|
|
|
|
|
if textTemplateTmp is not None:
|
|
|
|
|
resS = funcSearch(textTemplateTmp)
|
|
|
|
|
else:
|
|
|
|
|
resS = None
|
|
|
|
|
except PermissionError:
|
|
|
|
|
self.printWARNING(_("Permission denied for function %s. Did you set 'x' permissions?" % pathJoin(primeTemp, 'scripts/functions/', execName)))
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, '')
|
|
|
|
|
resS = funcSearch(textTemplateTmp)
|
|
|
|
|
except Exception:
|
|
|
|
|
self.printWARNING(_("Failed to apply custom function %s" % pathJoin(primeTemp, 'scripts/functions/', execName)))
|
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, '')
|
|
|
|
|
resS = funcSearch(textTemplateTmp)
|
|
|
|
|
else:
|
|
|
|
|
resS = None
|
|
|
|
|
elif funcName in self.namesTemplateFunction:
|
|
|
|
|
# аргументы функции - '(' аргументы ')'
|
|
|
|
|
funArgv = funcEnd.rpartition(")")[0]
|
|
|
|
|