Detect .custom files by default

This commit is contained in:
VirtuBox
2019-08-25 23:30:05 +02:00
parent 2defb346e3
commit 1f342da054

View File

@@ -9,8 +9,18 @@ Render Templates
class WOTemplate(): class WOTemplate():
def tmpl_render(self, fileconf, template, data, overwrite=True): def tmpl_render(self, fileconf, template, data, overwrite=True):
data = dict(data) data = dict(data)
if (not overwrite): if (not os.path.isfile('{0}.custom'
if not os.path.isfile('{0}'.format(fileconf)): .format(fileconf))):
if (not overwrite):
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()
else:
Log.debug(self, 'Writting the configuration to ' Log.debug(self, 'Writting the configuration to '
'file {0}'.format(fileconf)) 'file {0}'.format(fileconf))
wo_template = open('{0}'.format(fileconf), wo_template = open('{0}'.format(fileconf),
@@ -19,20 +29,10 @@ class WOTemplate():
out=wo_template) out=wo_template)
wo_template.close() wo_template.close()
else: else:
if (not os.path.isfile('{0}.custom' Log.debug(self, 'Writting the configuration to '
.format(fileconf))): 'file {0}.orig'.format(fileconf))
Log.debug(self, 'Writting the configuration to ' wo_template = open('{0}.orig'.format(fileconf),
'file {0}'.format(fileconf)) encoding='utf-8', mode='w')
wo_template = open('{0}'.format(fileconf), self.app.render((data), '{0}'.format(template),
encoding='utf-8', mode='w') out=wo_template)
self.app.render((data), '{0}'.format(template), wo_template.close()
out=wo_template)
wo_template.close()
else:
Log.debug(self, 'Writting the configuration to '
'file {0}.orig'.format(fileconf))
wo_template = open('{0}.orig'.format(fileconf),
encoding='utf-8', mode='w')
self.app.render((data), '{0}'.format(template),
out=wo_template)
wo_template.close()