Browse Source

_config does not need to be attached to self

pull/232/head
Oliverpool 9 years ago
parent
commit
177940f7ec
  1. 36
      patacrep/build.py

36
patacrep/build.py

@ -60,44 +60,44 @@ class Songbook:
- output: a file object, in which the file will be written. - output: a file object, in which the file will be written.
""" """
# Updating configuration # Updating configuration
self._config = self._raw_config.copy() tex_config = self._raw_config.copy()
renderer = TexBookRenderer( renderer = TexBookRenderer(
self._config['book']['template'], tex_config['book']['template'],
self._config['_datadir'], tex_config['_datadir'],
self._config['book']['lang'], tex_config['book']['lang'],
self._config['book']['encoding'], tex_config['book']['encoding'],
) )
try: try:
self._config['_template'] = renderer.get_all_variables(self._config.get('template', {})) tex_config['_template'] = renderer.get_all_variables(tex_config.get('template', {}))
except errors.SchemaError as exception: except errors.SchemaError as exception:
exception.message = "The songbook file '{}' is not valid\n{}".format( exception.message = "The songbook file '{}' is not valid\n{}".format(
self.basename, exception.message) self.basename, exception.message)
raise exception raise exception
self._config['_compiled_authwords'] = authors.compile_authwords( tex_config['_compiled_authwords'] = authors.compile_authwords(
copy.deepcopy(self._config['authors']) copy.deepcopy(tex_config['authors'])
) )
# Configuration set # Configuration set
self._config['render'] = content.render tex_config['render'] = content.render
self._config['content'] = content.process_content( tex_config['content'] = content.process_content(
self._config.get('content', []), tex_config.get('content', []),
self._config, tex_config,
) )
self._config['filename'] = output.name[:-4] tex_config['filename'] = output.name[:-4]
# Processing special options # Processing special options
self._config['_bookoptions'] = iter_bookoptions(self._config) tex_config['_bookoptions'] = iter_bookoptions(tex_config)
self._config['chords']['_notenames'] = self._get_chord_names( tex_config['chords']['_notenames'] = self._get_chord_names(
self._config['chords']['notation'] tex_config['chords']['notation']
) )
renderer.render_tex(output, self._config) renderer.render_tex(output, tex_config)
# Get all errors, and maybe exit program # Get all errors, and maybe exit program
self._errors.extend(renderer.errors) self._errors.extend(renderer.errors)
if self._config['_error'] == "failonbook": if tex_config['_error'] == "failonbook":
if self.has_errors(): if self.has_errors():
raise errors.SongbookError("Some songs contain errors. Stopping as requested.") raise errors.SongbookError("Some songs contain errors. Stopping as requested.")

Loading…
Cancel
Save