From c13334e9471dc4416ddd8ab34d271cf9335ead88 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 12 Jun 2016 19:00:52 +0200 Subject: [PATCH 1/3] Consider 'error' argument for the songlist parsing --- patacrep/content/__init__.py | 8 ++++++++ patacrep/data/templates/songbook_model.yml | 1 + 2 files changed, 9 insertions(+) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index a65b0525..5cae9d2d 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -185,6 +185,12 @@ class ContentList: continue yield from item.iter_errors() + def has_errors(self): + """Return `True` iff errors has been found.""" + for _ in self.iter_errors(): + return True + return False + class EmptyContentList(ContentList): """Empty content list: contain only errors.""" def __init__(self, *, errors): @@ -281,4 +287,6 @@ def process_content(content, config=None): contentlist.append_error(error) else: contentlist.append_error(ContentError(str(elem), "Unknown content type.")) + if contentlist.has_errors() and config['_error'] in ("failonsong", "failonbook"): + raise ContentError("Error while parsing the 'content' section of the songbook. Stopping as requested.") return contentlist diff --git a/patacrep/data/templates/songbook_model.yml b/patacrep/data/templates/songbook_model.yml index e1418e97..7ea6028a 100644 --- a/patacrep/data/templates/songbook_model.yml +++ b/patacrep/data/templates/songbook_model.yml @@ -99,6 +99,7 @@ schema: - type: //nil default: en: + _error: "fix" _datadir: [] # For test reasons book: lang: en From 5d6d56983cb9ec23d73e0389650ea54ac9634ab2 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 12 Jun 2016 20:54:27 +0200 Subject: [PATCH 2/3] Correct line length --- patacrep/content/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index 5cae9d2d..275f332a 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -288,5 +288,7 @@ def process_content(content, config=None): else: contentlist.append_error(ContentError(str(elem), "Unknown content type.")) if contentlist.has_errors() and config['_error'] in ("failonsong", "failonbook"): - raise ContentError("Error while parsing the 'content' section of the songbook. Stopping as requested.") + raise ContentError( + "Error while parsing the 'content' section of the songbook. Stopping as requested." + ) return contentlist From 89475a5ad94738ba263cd3cd94b7c695fd8dc369 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 12 Jun 2016 21:02:38 +0200 Subject: [PATCH 3/3] update news --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 963a654d..90e6b824 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,9 @@ * Bugfixes * The capo directive of the Chordpro files is now considered [#224](https://github.com/patacrep/patacrep/pull/224) * Chordpro files don't need to end with a trailing line [#223](https://github.com/patacrep/patacrep/pull/223) +* Enhancements + * Error management + * The 'error' option is considered for contentlist errors (incorrect syntax for instance) [#226](https://github.com/patacrep/patacrep/pull/226) # patacrep 5.0.0