From cd0d0ae0a54cda1c6fc56c2db5f0a243497d263d Mon Sep 17 00:00:00 2001 From: Luthaf Date: Sun, 6 Apr 2014 21:24:49 +0100 Subject: [PATCH] =?UTF-8?q?Changement=20de=20la=20valeur=20par=20d=C3=A9fa?= =?UTF-8?q?ut=20de=20titleprefixwords=20fix=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/build.py | 26 ++++++++++++----------- songbook_core/data/templates/default.tex | 8 ++++--- songbook_core/data/templates/patacrep.tex | 7 +++++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/songbook_core/build.py b/songbook_core/build.py index 25b0944d..d832924a 100644 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -41,31 +41,32 @@ class Songbook(object): # Default values: will be updated while parsing raw_songbook self.config = { 'template': "default.tex", - 'titleprefixwords': [], - 'authwords': {}, - 'lang': 'french', + 'lang': 'english', 'sort': [u"by", u"album", u"@title"], 'content': None, 'datadir': os.path.abspath('.'), } self.songslist = None self._parse(raw_songbook) - self._set_songs_default() - def _set_songs_default(self): - """Set the default values for the Song() class.""" - Song.sort = self.config['sort'] - Song.prefixes = self.config['titleprefixwords'] + def _set_songs_default(self, config): + """Set the default values for the Song() class. + + Argument: + - config : a dictionary containing the configuration + """ + Song.sort = config['sort'] + Song.prefixes = config['titleprefixwords'] Song.authwords['after'] = [ re.compile(r"^.*%s\b(.*)" % after) for after - in self.config['authwords']["after"] + in config['authwords']["after"] ] - Song.authwords['ignore'] = self.config['authwords']['ignore'] + Song.authwords['ignore'] = config['authwords']['ignore'] Song.authwords['sep'] = [ re.compile(r"^(.*)%s (.*)$" % sep) for sep in ([ - " %s" % sep for sep in self.config['authwords']["sep"] + " %s" % sep for sep in config['authwords']["sep"] ] + [',']) ] @@ -112,12 +113,13 @@ class Songbook(object): ) context = renderer.get_variables() - context.update(self.config) context['titleprefixkeys'] = ["after", "sep", "ignore"] context['songlist'] = self.songslist context['filename'] = output.name[:-4] + self._set_songs_default(context) + renderer.render_tex(output, context) diff --git a/songbook_core/data/templates/default.tex b/songbook_core/data/templates/default.tex index e5030413..2873ea69 100644 --- a/songbook_core/data/templates/default.tex +++ b/songbook_core/data/templates/default.tex @@ -52,10 +52,12 @@ "default": {"default": "\\begin{flushright}Generated using Songbook (\\url{http://www.patacrep.com})\\end{flushright}"} }, "titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles", - "french": "Ignore des mots dans le classement des chansons"} + "french": "Ignore des mots dans le classement des chansons"}, + "default": {"default": []} }, -"authwords": {"descriptipn": {"english": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)", - "french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"} +"authwords": {"description": {"english": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)", + "french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"}, + "default": {"default": {}} } } (* endvariables *) diff --git a/songbook_core/data/templates/patacrep.tex b/songbook_core/data/templates/patacrep.tex index cf98d049..94ba4db4 100644 --- a/songbook_core/data/templates/patacrep.tex +++ b/songbook_core/data/templates/patacrep.tex @@ -32,7 +32,12 @@ "indexbgcolor": {"description": {"english": "Index Shade", "french": "Couleur d'index"}, "type": "color", "default": {"default": "D1E4AE"} - } + }, +"titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles", + "french": "Ignore des mots dans le classement des chansons"}, + "default": {"default": ["The", "Le", "La", "L'", "A", "Au", "Ces", "De", + "Des", "El", "Les", "Ma", "Mon", "Un"]} + } } (* endvariables *)