From 72ed4d820abae9cf0632874c714818a866360440 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 19 Aug 2019 18:23:29 +0200 Subject: [PATCH] Create .orig version of custom config --- wo/core/template.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wo/core/template.py b/wo/core/template.py index 2227b77..a39200b 100644 --- a/wo/core/template.py +++ b/wo/core/template.py @@ -8,9 +8,9 @@ Render Templates class WOTemplate(): def tmpl_render(self, fileconf, template, data, overwrite=True): + data = dict(data) if (not overwrite): if not os.path.isfile('{0}'.format(fileconf)): - data = dict(data) Log.debug(self, 'Writting the configuration to ' 'file {0}'.format(fileconf)) wo_template = open('{0}'.format(fileconf), @@ -21,7 +21,6 @@ class WOTemplate(): else: if (not os.path.isfile('{0}.custom' .format(fileconf))): - data = dict(data) Log.debug(self, 'Writting the configuration to ' 'file {0}'.format(fileconf)) wo_template = open('{0}'.format(fileconf), @@ -29,3 +28,11 @@ class WOTemplate(): self.app.render((data), '{0}'.format(template), 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()