support of variables's file_name
This commit is contained in:
@ -11,8 +11,8 @@ import logging
|
||||
from typing import Dict
|
||||
|
||||
from subprocess import call
|
||||
from os import listdir, unlink, mkdir
|
||||
from os.path import basename, join, split, isfile, isdir
|
||||
from os import listdir, unlink, makedirs
|
||||
from os.path import dirname, basename, join, split, isfile, isdir
|
||||
|
||||
from tempfile import mktemp
|
||||
|
||||
@ -114,14 +114,16 @@ class CheetahTemplate(ChtTemplate):
|
||||
context,
|
||||
eosfunc: Dict,
|
||||
config: Config,
|
||||
current_container: str):
|
||||
current_container: str,
|
||||
destfilename):
|
||||
"""Initialize Creole CheetahTemplate
|
||||
"""
|
||||
ChtTemplate.__init__(self, file=filename,
|
||||
searchList=[context, eosfunc, {'is_defined' : IsDefined(context),
|
||||
'creole_client' : CreoleClient(config),
|
||||
'current_container':CreoleGet(current_container),
|
||||
}])
|
||||
'rougail_filename': destfilename
|
||||
}])
|
||||
|
||||
|
||||
class CreoleLeader:
|
||||
@ -326,11 +328,13 @@ class CreoleTemplateEngine:
|
||||
# full path of the destination file
|
||||
log.info(_(f"Cheetah processing: '{destfilename}'"))
|
||||
try:
|
||||
cheetah_template = CheetahTemplate(join(self.tmp_dir, filevar['source']),
|
||||
cheetah_template = CheetahTemplate(join(self.tmp_dir,
|
||||
filevar['source']),
|
||||
self.creole_variables_dict,
|
||||
self.eosfunc,
|
||||
self.config.config.copy(),
|
||||
container)
|
||||
container,
|
||||
destfilename)
|
||||
data = str(cheetah_template)
|
||||
except CheetahNotFound as err:
|
||||
varname = err.args[0][13:-1]
|
||||
@ -386,15 +390,18 @@ class CreoleTemplateEngine:
|
||||
log.info(_("Instantiating file '{filename}'"))
|
||||
container_dir = join(self.dest_dir,
|
||||
container)
|
||||
if not isdir(container_dir):
|
||||
mkdir(container_dir)
|
||||
destfilename = join(container_dir,
|
||||
filevar['source'])
|
||||
self.process(destfilename,
|
||||
filevar,
|
||||
container)
|
||||
self.change_properties(destfilename,
|
||||
filevar)
|
||||
filenames = filevar['name']
|
||||
if not isinstance(filenames, list):
|
||||
filenames = [filenames]
|
||||
for filename in filenames:
|
||||
destfilename = join(container_dir,
|
||||
filename[1:])
|
||||
makedirs(dirname(destfilename), exist_ok=True)
|
||||
self.process(destfilename,
|
||||
filevar,
|
||||
container)
|
||||
self.change_properties(destfilename,
|
||||
filevar)
|
||||
|
||||
def instance_files(self,
|
||||
container=None):
|
||||
|
Reference in New Issue
Block a user