From 5dc1cf415f88da003c6f89e4603073a95a511c6c Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 16 Jun 2014 06:49:11 +0200 Subject: [PATCH] Solving error in management of default values of configuration --- songbook_core/build.py | 46 +++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/songbook_core/build.py b/songbook_core/build.py index 213cb8cb..2c8e5fa3 100755 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -81,46 +81,38 @@ class Songbook(object): for path in self.config['datadir'] ] - def build_config(self, from_templates): - """Build configuration dictionary - - This dictionary is assembled using (by order of least precedence): - - the hard-coded default; - - the values read from templates; - - the values read from .sb file. - """ - config = DEFAULT_CONFIG - config.update(from_templates) - config.update(self.config) - - # Post-processing - config['authwords'] = authors.compile_authwords(config['authwords']) - - return config - def write_tex(self, output): """Build the '.tex' file corresponding to self. Arguments: - output: a file object, in which the file will be written. """ + # Updating configuration + config = DEFAULT_CONFIG + config.update(self.config) renderer = TexRenderer( - self.config['template'], - self.config['datadir'], - self.config['lang'], + config['template'], + config['datadir'], + config['lang'], ) + config.update(self.config) + config.update(renderer.get_variables()) + + config['authwords'] = authors.compile_authwords(config['authwords']) + + self.config = config + # Configuration set - context = self.build_config(renderer.get_variables()) self.contentlist = content.process_content( self.config.get('content', []), - context, + self.config, ) - context['render_content'] = content.render_content - context['titleprefixkeys'] = ["after", "sep", "ignore"] - context['content'] = self.contentlist - context['filename'] = output.name[:-4] + self.config['render_content'] = content.render_content + self.config['titleprefixkeys'] = ["after", "sep", "ignore"] + self.config['content'] = self.contentlist + self.config['filename'] = output.name[:-4] - renderer.render_tex(output, context) + renderer.render_tex(output, self.config) class SongbookBuilder(object):