|
@ -81,46 +81,38 @@ class Songbook(object): |
|
|
for path in self.config['datadir'] |
|
|
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): |
|
|
def write_tex(self, output): |
|
|
"""Build the '.tex' file corresponding to self. |
|
|
"""Build the '.tex' file corresponding to self. |
|
|
|
|
|
|
|
|
Arguments: |
|
|
Arguments: |
|
|
- output: a file object, in which the file will be written. |
|
|
- output: a file object, in which the file will be written. |
|
|
""" |
|
|
""" |
|
|
|
|
|
# Updating configuration |
|
|
|
|
|
config = DEFAULT_CONFIG |
|
|
|
|
|
config.update(self.config) |
|
|
renderer = TexRenderer( |
|
|
renderer = TexRenderer( |
|
|
self.config['template'], |
|
|
config['template'], |
|
|
self.config['datadir'], |
|
|
config['datadir'], |
|
|
self.config['lang'], |
|
|
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.contentlist = content.process_content( |
|
|
self.config.get('content', []), |
|
|
self.config.get('content', []), |
|
|
context, |
|
|
self.config, |
|
|
) |
|
|
) |
|
|
context['render_content'] = content.render_content |
|
|
self.config['render_content'] = content.render_content |
|
|
context['titleprefixkeys'] = ["after", "sep", "ignore"] |
|
|
self.config['titleprefixkeys'] = ["after", "sep", "ignore"] |
|
|
context['content'] = self.contentlist |
|
|
self.config['content'] = self.contentlist |
|
|
context['filename'] = output.name[:-4] |
|
|
self.config['filename'] = output.name[:-4] |
|
|
|
|
|
|
|
|
renderer.render_tex(output, context) |
|
|
renderer.render_tex(output, self.config) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SongbookBuilder(object): |
|
|
class SongbookBuilder(object): |
|
|