Example #1
0
    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
        self._config = self._raw_config.copy()
        renderer = TexBookRenderer(
            self._config['book']['template'],
            self._config['_datadir'],
            self._config['book']['lang'],
            self._config['book']['encoding'],
            )

        try:
            self._config['_template'] = renderer.get_all_variables(self._config.get('template', {}))
        except errors.SchemaError as exception:
            exception.message = "The songbook file '{}' is not valid\n{}".format(
                self.basename, exception.message)
            raise exception

        self._config['_compiled_authwords'] = authors.compile_authwords(
            copy.deepcopy(self._config['authors'])
            )

        # Loading custom plugins
        self._config['_content_plugins'] = files.load_plugins(
            datadirs=self._config['_datadir'],
            root_modules=['content'],
            keyword='CONTENT_PLUGINS',
            )
        self._config['_song_plugins'] = files.load_plugins(
            datadirs=self._config['_datadir'],
            root_modules=['songs'],
            keyword='SONG_RENDERERS',
            )['tsg']

        # Configuration set
        self._config['render'] = content.render
        self._config['content'] = content.process_content(
            self._config.get('content', []),
            self._config,
            )
        self._config['filename'] = output.name[:-4]

        self._config['_bookoptions'] = iter_bookoptions(self._config)

        renderer.render_tex(output, self._config)

        # Get all errors, and maybe exit program
        self._errors.extend(renderer.errors)
        if self._config['_error'] == "failonbook":
            if self.has_errors():
                raise errors.SongbookError("Some songs contain errors. Stopping as requested.")
Example #2
0
    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
        self._config = self._raw_config.copy()
        renderer = TexBookRenderer(
            self._config['book']['template'],
            self._config['_datadir'],
            self._config['book']['lang'],
            self._config['book']['encoding'],
        )

        try:
            self._config['_template'] = renderer.get_all_variables(
                self._config.get('template', {}))
        except errors.SchemaError as exception:
            exception.message = "The songbook file '{}' is not valid\n{}".format(
                self.basename, exception.message)
            raise exception

        self._config['_compiled_authwords'] = authors.compile_authwords(
            copy.deepcopy(self._config['authors']))

        # Configuration set
        self._config['render'] = content.render
        self._config['content'] = content.process_content(
            self._config.get('content', []),
            self._config,
        )
        self._config['filename'] = output.name[:-4]

        # Processing special options
        self._config['_bookoptions'] = iter_bookoptions(self._config)
        self._config['chords']['_notenames'] = self._get_chord_names(
            self._config['chords']['notation'])

        renderer.render_tex(output, self._config)

        # Get all errors, and maybe exit program
        self._errors.extend(renderer.errors)
        if self._config['_error'] == "failonbook":
            if self.has_errors():
                raise errors.SongbookError(
                    "Some songs contain errors. Stopping as requested.")
Example #3
0
    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
        tex_config = self._raw_config.copy()
        renderer = TexBookRenderer(
            tex_config['book']['template'],
            tex_config['_datadir'],
            tex_config['book']['lang'],
            tex_config['book']['encoding'],
            )

        try:
            tex_config['_template'] = renderer.get_all_variables(tex_config.get('template', {}))
        except errors.SchemaError as exception:
            exception.message = "The songbook file '{}' is not valid\n{}".format(
                self.basename, exception.message)
            raise exception

        tex_config['_compiled_authwords'] = authors.compile_authwords(
            copy.deepcopy(tex_config['authors'])
            )

        # Configuration set
        tex_config['render'] = content.render
        tex_config['_langs'], tex_config['content'] = self.get_content_items()
        tex_config['filename'] = output.name[:-4]

        # Processing special options
        tex_config['_bookoptions'] = iter_bookoptions(tex_config)
        tex_config['chords']['_notenames'] = self._get_chord_names(
            tex_config['chords']['notation']
            )

        renderer.render_tex(output, tex_config)

        # Get all errors, and maybe exit program
        self._errors.extend(renderer.errors)
        if tex_config['_error'] == "failonbook":
            if self.has_errors():
                raise errors.SongbookError("Some songs contain errors. Stopping as requested.")
Example #4
0
    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
        self._config = DEFAULT_CONFIG.copy()
        self._config.update(self._raw_config)
        renderer = TexBookRenderer(
            self._config["template"], self._config["datadir"], self._config["lang"], self._config["encoding"]
        )
        self._config.update(renderer.get_variables())
        self._config.update(self._raw_config)

        self._config["_compiled_authwords"] = authors.compile_authwords(copy.deepcopy(self._config["authwords"]))

        # Loading custom plugins
        self._config["_content_plugins"] = files.load_plugins(
            datadirs=self._config.get("datadir", []), root_modules=["content"], keyword="CONTENT_PLUGINS"
        )
        self._config["_song_plugins"] = files.load_plugins(
            datadirs=self._config.get("datadir", []), root_modules=["songs"], keyword="SONG_RENDERERS"
        )["tsg"]

        # Configuration set
        self._config["render"] = content.render
        self._config["content"] = content.process_content(self._config.get("content", []), self._config)
        self._config["filename"] = output.name[:-4]

        renderer.render_tex(output, self._config)

        # Get all errors, and maybe exit program
        self._errors.extend(renderer.errors)
        if self.config["_error"] == "failonbook":
            if self.has_errors():
                raise errors.SongbookError("Some songs contain errors. Stopping as requested.")