From fa8674d6a0c360a9df028a681c6c95d9d3854eed Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 14 Jun 2014 20:45:28 +0200 Subject: [PATCH] =?UTF-8?q?Introduction=20d'un=20param=C3=A8tre=20config['?= =?UTF-8?q?songdir']=20;=20Peuplement=20par=20d=C3=A9faut=20de=20content?= =?UTF-8?q?=20avec=20le=20premier=20des=20r=C3=A9pertoires=20de=20songdir?= =?UTF-8?q?=20non=20vide.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/build.py | 1 + songbook_core/content/song.py | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/songbook_core/build.py b/songbook_core/build.py index 86c7433d..5e26a720 100755 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -75,6 +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']] def build_config(self, from_templates): config = DEFAULT_CONFIG diff --git a/songbook_core/content/song.py b/songbook_core/content/song.py index 1aeaf15e..38948e28 100644 --- a/songbook_core/content/song.py +++ b/songbook_core/content/song.py @@ -37,21 +37,17 @@ def parse(keyword, argument, contentlist, config): if 'languages' not in config: config['languages'] = set() songlist = [] - if not contentlist: + for songdir in config['songdir']: + if contentlist: + break contentlist = [ - os.path.relpath( - filename, - os.path.join(config['datadir'][0], 'songs'), - ) + os.path.relpath(filename, songdir) for filename - in recursive_find( - os.path.join(config['datadir'][0], 'songs'), - "*.sg" - ) + in recursive_find(songdir, "*.sg") ] for elem in contentlist: before = len(songlist) - for songdir in [os.path.join(d, 'songs') for d in config['datadir']]: + 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)