|
@ -1,4 +1,4 @@ |
|
|
"""Change base directory before importing songs.""" |
|
|
"""Add a path directory to the 'songdir' list.""" |
|
|
|
|
|
|
|
|
from patacrep.content import process_content, validate_parser_argument |
|
|
from patacrep.content import process_content, validate_parser_argument |
|
|
from patacrep.songs import DataSubpath |
|
|
from patacrep.songs import DataSubpath |
|
@ -6,39 +6,35 @@ from patacrep.songs import DataSubpath |
|
|
#pylint: disable=unused-argument |
|
|
#pylint: disable=unused-argument |
|
|
@validate_parser_argument(""" |
|
|
@validate_parser_argument(""" |
|
|
type: //rec |
|
|
type: //rec |
|
|
required: |
|
|
|
|
|
path: //str |
|
|
|
|
|
optional: |
|
|
optional: |
|
|
content: //any |
|
|
content: //any |
|
|
|
|
|
required: |
|
|
|
|
|
path: //str |
|
|
""") |
|
|
""") |
|
|
def parse(keyword, config, argument): |
|
|
def parse(keyword, config, argument): |
|
|
"""Return a list songs, whith a different base path. |
|
|
"""Return a list of songs, whith an another base path. |
|
|
|
|
|
|
|
|
Arguments: |
|
|
Arguments: |
|
|
- keyword: unused; |
|
|
- keyword: unused; |
|
|
- config: the current songbook configuration dictionary; |
|
|
- config: the current songbook configuration dictionary; |
|
|
- argument: a dict containing: |
|
|
- argument: a dict containing: |
|
|
path: string specifying the path to use as root; |
|
|
path: string specifying the path to add to the songdirs list; |
|
|
content: songbook content, that is parsed by |
|
|
content: songbook content, that is parsed by |
|
|
patacrep.content.process_content(). |
|
|
patacrep.content.process_content(). |
|
|
|
|
|
|
|
|
This function adds 'path' 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 'path' is added: |
|
|
The 'path' is added as a relative path to the dir of the songbook file. |
|
|
- first as a relative path to the *.yaml file directory; |
|
|
|
|
|
- then as a relative path to every path already present in |
|
|
|
|
|
config['songdir'] (which are 'song' dir inside the datadirs). |
|
|
|
|
|
""" |
|
|
""" |
|
|
subpath = argument['path'] |
|
|
subpath = argument['path'] |
|
|
old_songdir = config['_songdir'] |
|
|
old_songdir = config['_songdir'] |
|
|
|
|
|
|
|
|
config['_songdir'] = [path.clone().join(subpath) for path in config['_songdir']] |
|
|
config['_songdir'] = [DataSubpath(config['_songbookfile_dir'], subpath)] |
|
|
if '_songbookfile_dir' in config: |
|
|
config['_songdir'].extend(old_songdir) |
|
|
config['_songdir'].insert(0, DataSubpath(config['_songbookfile_dir'], subpath)) |
|
|
|
|
|
|
|
|
|
|
|
processed_content = process_content(argument.get('content'), config) |
|
|
processed_content = process_content(argument.get('content'), config) |
|
|
config['_songdir'] = old_songdir |
|
|
config['_songdir'] = old_songdir |
|
|
return processed_content |
|
|
return processed_content |
|
|
|
|
|
|
|
|
CONTENT_PLUGINS = {'cwd': parse} |
|
|
CONTENT_PLUGINS = {'addsongdir': parse} |