Browse Source

cwd is now in yaml

pull/190/head
Oliverpool 9 years ago
parent
commit
a37966e589
  1. 22
      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

22
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

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
- ["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"]
Loading…
Cancel
Save