From c1e8ac80ed3eda5e823eee70a4a4768798011916 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 26 Apr 2016 06:30:03 +0200 Subject: [PATCH] Do not split definition of chord notation between python module and template --- patacrep/build.py | 14 +++++++++----- patacrep/data/templates/songbook/default.tex | 6 ------ patacrep/data/templates/songbook_model.yml | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index ce2ee802..f349c02c 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -111,7 +111,7 @@ class Songbook: # Processing special options self._config['_bookoptions'] = iter_bookoptions(self._config) - self._config['chords']['_notenames'] = self._process_chord_notation( + self._config['chords']['_notenames'] = self._get_chord_names( self._config['chords']['notation'] ) @@ -123,13 +123,17 @@ class Songbook: if self.has_errors(): raise errors.SongbookError("Some songs contain errors. Stopping as requested.") - def _process_chord_notation(self, notation): - notation = notation.strip() - if notation in ['solfedge', 'alphascale']: - return notation + def _get_chord_names(self, notation): + """Return a list of chord names, given the user option.""" + if notation == "alphascale": + 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 " diff --git a/patacrep/data/templates/songbook/default.tex b/patacrep/data/templates/songbook/default.tex index 0e62f0a5..1b02b2d3 100644 --- a/patacrep/data/templates/songbook/default.tex +++ b/patacrep/data/templates/songbook/default.tex @@ -85,13 +85,7 @@ description: \authsepword{((word))} (* endfor *) -(* if chords._notenames == "alphascale" -*) - \notenamesout{A}{B}{C}{D}{E}{F}{G} -(* elif chords._notenames == "solfedge" -*) - \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} -(* else -*) \notenamesout{(( chords._notenames[0] ))}{(( chords._notenames[1] ))}{(( chords._notenames[2] ))}{(( chords._notenames[3] ))}{(( chords._notenames[4] ))}{(( chords._notenames[5] ))}{(( chords._notenames[6] ))} -(* endif *) (* endblock *) (* block title *) diff --git a/patacrep/data/templates/songbook_model.yml b/patacrep/data/templates/songbook_model.yml index af8320f8..045c0876 100644 --- a/patacrep/data/templates/songbook_model.yml +++ b/patacrep/data/templates/songbook_model.yml @@ -152,7 +152,7 @@ description: lilypond: "Display lilypond scores" tablatures: "Display tablatures" instrument: "Instrument for the diagrams" - notation: "Chord notation. Can be `solfedge`, `alphascale`, or a space separated list of note names." + 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`." authors: separators: "Separator words between artists" @@ -178,7 +178,7 @@ description: lilypond: "Inclure les partitions lilypond" tablatures: "Inclure les tablatures" instrument: "Instrument pour les diagrammes d'accords" - notation: "Notation des accords. Peut être `solfedge` (DO RE MI...), `alphascale` (A B C...), ou une liste des noms de notes séparés par des espaces, en commençant par LA." + 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`." authors: separators: "Mots de séparation entre les artistes"