From 13322630ab69cc7146d1d334fd079c6529589c2a Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 14 Jun 2014 20:50:49 +0200 Subject: [PATCH] =?UTF-8?q?Introduction=20de=20variables=20de=20configurat?= =?UTF-8?q?ion=20priv=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les variables dont le nom commence par `_` sont privées : elles ne peuvent pas être assignées dans le fichier songbook ou dans un template, et sont destinées à un usage interne. --- songbook_core/build.py | 2 +- songbook_core/content/cwd.py | 6 +++--- songbook_core/content/song.py | 8 ++++---- songbook_core/data/templates/songs.tex | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/songbook_core/build.py b/songbook_core/build.py index 5e26a720..6a2a01e6 100755 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -75,7 +75,7 @@ class Songbook(object): abs_datadir.append(__DATADIR__) self.config['datadir'] = abs_datadir - self.config['songdir'] = [os.path.join(path, 'songs') for path in self.config['datadir']] + self.config['_songdir'] = [os.path.join(path, 'songs') for path in self.config['datadir']] def build_config(self, from_templates): config = DEFAULT_CONFIG diff --git a/songbook_core/content/cwd.py b/songbook_core/content/cwd.py index 6c76d8c2..a9c5053e 100644 --- a/songbook_core/content/cwd.py +++ b/songbook_core/content/cwd.py @@ -6,10 +6,10 @@ import os from songbook_core.content import process_content def parse(keyword, config, argument, contentlist): - config['songdir'] = ( + config['_songdir'] = ( [os.path.relpath(argument)] + - [os.path.join(path, argument) for path in config['songdir']] + - config['songdir'] + [os.path.join(path, argument) for path in config['_songdir']] + + config['_songdir'] ) return process_content(contentlist, config) diff --git a/songbook_core/content/song.py b/songbook_core/content/song.py index 38948e28..fbaae8d7 100644 --- a/songbook_core/content/song.py +++ b/songbook_core/content/song.py @@ -35,9 +35,9 @@ class SongRenderer(Content, Song): def parse(keyword, argument, contentlist, config): if 'languages' not in config: - config['languages'] = set() + config['_languages'] = set() songlist = [] - for songdir in config['songdir']: + for songdir in config['_songdir']: if contentlist: break contentlist = [ @@ -47,12 +47,12 @@ def parse(keyword, argument, contentlist, config): ] for elem in contentlist: before = len(songlist) - for songdir in config['songdir']: + for songdir in config['_songdir']: for filename in glob.iglob(os.path.join(songdir, elem)): LOGGER.debug('Parsing file "{}"…'.format(filename)) song = SongRenderer(filename, config) songlist.append(song) - config["languages"].update(song.languages) + config["_languages"].update(song.languages) if len(songlist) > before: break if len(songlist) == before: diff --git a/songbook_core/data/templates/songs.tex b/songbook_core/data/templates/songs.tex index f81db077..7e51e0bb 100644 --- a/songbook_core/data/templates/songs.tex +++ b/songbook_core/data/templates/songs.tex @@ -70,7 +70,7 @@ (* block songbookpreambule *) (( super() )) - (* for lang in languages *) + (* for lang in _languages *) \PassOptionsToPackage{((lang))}{babel} (* endfor *) \usepackage[((lang))]{babel}