Browse Source

cwd is now in yaml

pull/190/head
Oliverpool 9 years ago
parent
commit
a37966e589
  1. 20
      patacrep/content/cwd.py
  2. 4
      test/test_content/cwd.source
  3. 12
      test/test_content/cwd_list.source
  4. 10
      test/test_songbook/content.sb

20
patacrep/content/cwd.py

@ -4,30 +4,32 @@ from patacrep.content import process_content
from patacrep.songs import DataSubpath from patacrep.songs import DataSubpath
#pylint: disable=unused-argument #pylint: disable=unused-argument
def parse(keyword, config, argument, contentlist): def parse(keyword, config, argument):
"""Return a list songs included in contentlist, whith a different base path. """Return a list songs, whith a different base path.
Arguments: Arguments:
- keyword: unused; - keyword: unused;
- config: the current songbook configuration dictionary; - config: the current songbook configuration dictionary;
- argument: a directory; - argument: a dict containing:
- contentlist: songbook content, that is parsed by path: string specifying the path to use as root;
content: songbook content, that is parsed by
patacrep.content.process_content(). 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. for, and then processes the content.
The 'argument' is added: The 'path' is added:
- first as a relative path to the current directory; - first as a relative path to the current directory;
- then as a relative path to every path already present in - then as a relative path to every path already present in
config['songdir']. config['songdir'].
""" """
subpath = argument['path']
old_songdir = config['_songdir'] old_songdir = config['_songdir']
config['_songdir'] = ( config['_songdir'] = (
[DataSubpath(".", argument)] + [DataSubpath(".", subpath)] +
[path.clone().join(argument) for path in config['_songdir']] [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 config['_songdir'] = old_songdir
return processed_content return processed_content

4
test/test_content/cwd.source

@ -1 +1,3 @@
[["cwd(subdir)"]] - cwd:
path: subdir
content:

12
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"] - cwd:
path: subdir
content:
- "exsong.sg"
- "intersong.is"
- "jsonlist.json"
- "texfile.tex"
- "texsong.tsg"
- "chordpro.csg"
- "subdir/chordpro.csg"
- "exsong.sg"

10
test/test_songbook/content.sb

@ -10,8 +10,10 @@ content:
- section: Test of section - section: Test of section
- ["sorted"] - ["sorted"]
- songsection: Test of song section - songsection: Test of song section
- ["cwd(content_datadir/content)", - cwd:
"song.csg", "song.tsg", path: content_datadir/content
["tex", "foo.tex"] content:
] - "song.csg"
- "song.tsg"
- ["tex", "foo.tex"]
- ["include", "include.sbc"] - ["include", "include.sbc"]
Loading…
Cancel
Save