Browse Source

Introduction de variables de configuration privées

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.
pull/47/head
Louis 11 years ago
parent
commit
13322630ab
  1. 2
      songbook_core/build.py
  2. 6
      songbook_core/content/cwd.py
  3. 8
      songbook_core/content/song.py
  4. 2
      songbook_core/data/templates/songs.tex

2
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

6
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)

8
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:

2
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}

Loading…
Cancel
Save