Files
WPIQ/wo/core/template.py
VirtuBox 8664dd9d21 Add WOTemplate
* Add new function to handle rendering template
* Make a copy of php configuration and use this copy to create new config files
2019-08-19 17:40:21 +02:00

29 lines
1.0 KiB
Python

from wo.core.logging import Log
import os
"""
Render Templates
"""
class WOTemplate():
def tmpl_render(self, fileconf, template, data, overwrite=False):
if overwrite:
data = dict(data)
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()
else:
if not os.path.isfile('{0}'.format(fileconf)):
Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()