From f8e99316701f9f042876869dabaaa8a99f4d39dc Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 26 Apr 2016 07:56:38 +0200 Subject: [PATCH] Chord names must be given as an array (instead of a space separated list) --- patacrep/build.py | 27 +--------------------- patacrep/data/templates/songbook_model.yml | 16 ++++++++++--- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index f349c02c..cd11a1ee 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -29,16 +29,6 @@ GENERATED_EXTENSIONS = [ "_title.sxd", ] -class BookError(errors.SharedError): - """Global book error.""" - - def __init__(self, message): - super().__init__() - self.message = message - - def __str__(self): - return self.message - # pylint: disable=too-few-public-methods class Songbook: """Represent a songbook (.yaml) file. @@ -129,22 +119,7 @@ class Songbook: return ["A", "B", "C", "D", "E", "F", "G"] if notation == "solfedge": return ["La", "Si", "Do", r"R\'e", "Mi", "Fa", "Sol"] - - names = notation.split(" ") - if len(names) == 7: - return names - - error = BookError( - "Option `notation` of section `chords` must be `solfedge`, " - "`alphascale` or a space separated list of exactly seven note " - "names." - ) - self._errors.append(error) - LOGGER.warning(str(error)) - if len(names) < 7: - return names + ["?"] * (7-len(names)) - else: - return names[:7] + return notation def has_errors(self): """Return `True` iff errors have been encountered in the book. diff --git a/patacrep/data/templates/songbook_model.yml b/patacrep/data/templates/songbook_model.yml index 045c0876..2fa193d7 100644 --- a/patacrep/data/templates/songbook_model.yml +++ b/patacrep/data/templates/songbook_model.yml @@ -56,7 +56,17 @@ schema: - type: //str value: "ukulele" notation: - type: //str + type: //any + of: + - type: //str + value: "alphascale" + - type: //str + value: "solfedge" + - type: //arr + contents: //str + length: + min: 7 + max: 7 authors: type: //rec required: @@ -152,7 +162,7 @@ description: lilypond: "Display lilypond scores" tablatures: "Display tablatures" instrument: "Instrument for the diagrams" - notation: "Space separated list of chord names, with special values `solfedge` being an alias for `La Si Do Ré Mi Fa Sol`, and `alphascale` for `A B C D E F G`." + notation: "List of chord names, with special values `solfedge` being an alias for `La Si Do Ré Mi Fa Sol`, and `alphascale` for `A B C D E F G`." authors: separators: "Separator words between artists" @@ -178,7 +188,7 @@ description: lilypond: "Inclure les partitions lilypond" tablatures: "Inclure les tablatures" instrument: "Instrument pour les diagrammes d'accords" - notation: "Liste des noms de notes, séparés par des espaces, en commençant par LA, sachant que `solfedge` est un alias pour `La Si Do Ré Mi Fa Sol`, et `alphascale` pour `A B C D E F G`." + notation: "Liste des noms de notes, en commençant par LA, sachant que `solfedge` est un alias pour `La Si Do Ré Mi Fa Sol`, et `alphascale` pour `A B C D E F G`." authors: separators: "Mots de séparation entre les artistes"