From dd2147c6126915eb0a3bf1e44aded04c97a9c8d9 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 30 Dec 2015 21:32:52 +0100 Subject: [PATCH] Add an `iter_flat_error()` method --- patacrep/build.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/patacrep/build.py b/patacrep/build.py index 12315447..2fed6c31 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -132,6 +132,21 @@ class Songbook: contentlist = self._config.get('content', content.ContentList()) yield from contentlist.iter_errors() + def iter_flat_errors(self): + """Iterate over errors, in an exportable format. + + This function does the same job as :func:`iter_errors`, exepted that + the errors are represented as dictionaries of standard python types. + + Each error (dictionary) contains the following keys: + - `type`: the error type (as the class name of the error); + - `message`: Error message, that does not include the error location (datadir, song, etc.); + - `full_message`: Error message, containing the full error location; + - depending on the error type, more keys may be present in the error. + """ + for error in self.iter_errors(): + yield vars(error) + def requires_lilypond(self): """Tell if lilypond is part of the bookoptions""" return 'lilypond' in self.config.get('bookoptions', [])