From a37966e5890696d459d295bd3464fb13af99f63d Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Tue, 12 Jan 2016 13:29:18 +0100 Subject: [PATCH] cwd is now in yaml --- patacrep/content/cwd.py | 22 ++++++++++++---------- test/test_content/cwd.source | 4 +++- test/test_content/cwd_list.source | 12 +++++++++++- test/test_songbook/content.sb | 10 ++++++---- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/patacrep/content/cwd.py b/patacrep/content/cwd.py index 07cc407e..bf7a7931 100755 --- a/patacrep/content/cwd.py +++ b/patacrep/content/cwd.py @@ -4,30 +4,32 @@ from patacrep.content import process_content from patacrep.songs import DataSubpath #pylint: disable=unused-argument -def parse(keyword, config, argument, contentlist): - """Return a list songs included in contentlist, whith a different base path. +def parse(keyword, config, argument): + """Return a list songs, whith a different base path. Arguments: - keyword: unused; - config: the current songbook configuration dictionary; - - argument: a directory; - - contentlist: songbook content, that is parsed by - patacrep.content.process_content(). + - argument: a dict containing: + path: string specifying the path to use as root; + content: songbook content, that is parsed by + patacrep.content.process_content(). - This function adds 'argument' to the directories where songs are searched + This function adds 'path' to the directories where songs are searched for, and then processes the content. - The 'argument' is added: + The 'path' is added: - first as a relative path to the current directory; - then as a relative path to every path already present in config['songdir']. """ + subpath = argument['path'] old_songdir = config['_songdir'] config['_songdir'] = ( - [DataSubpath(".", argument)] + - [path.clone().join(argument) for path in config['_songdir']] + [DataSubpath(".", subpath)] + + [path.clone().join(subpath) for path in config['_songdir']] ) - processed_content = process_content(contentlist, config) + processed_content = process_content(argument['content'], config) config['_songdir'] = old_songdir return processed_content diff --git a/test/test_content/cwd.source b/test/test_content/cwd.source index 4dfc53e6..1d0663d7 100644 --- a/test/test_content/cwd.source +++ b/test/test_content/cwd.source @@ -1 +1,3 @@ -[["cwd(subdir)"]] \ No newline at end of file +- cwd: + path: subdir + content: \ No newline at end of file diff --git a/test/test_content/cwd_list.source b/test/test_content/cwd_list.source index c5700449..15f85307 100644 --- a/test/test_content/cwd_list.source +++ b/test/test_content/cwd_list.source @@ -1 +1,11 @@ -[["cwd(subdir)", "exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"], "exsong.sg"] \ No newline at end of file +- cwd: + path: subdir + content: + - "exsong.sg" + - "intersong.is" + - "jsonlist.json" + - "texfile.tex" + - "texsong.tsg" + - "chordpro.csg" + - "subdir/chordpro.csg" +- "exsong.sg" \ No newline at end of file diff --git a/test/test_songbook/content.sb b/test/test_songbook/content.sb index 1aa5b0f7..4c57a262 100644 --- a/test/test_songbook/content.sb +++ b/test/test_songbook/content.sb @@ -10,8 +10,10 @@ content: - section: Test of section - ["sorted"] - songsection: Test of song section - - ["cwd(content_datadir/content)", - "song.csg", "song.tsg", - ["tex", "foo.tex"] - ] + - cwd: + path: content_datadir/content + content: + - "song.csg" + - "song.tsg" + - ["tex", "foo.tex"] - ["include", "include.sbc"] \ No newline at end of file