From 0481ce59625438cc9704550e581e01fd88c151be Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Wed, 13 Jan 2016 09:20:31 +0100 Subject: [PATCH] song plugin support argument --- patacrep/content/__init__.py | 4 ++-- patacrep/content/song.py | 2 ++ test/test_content/songs.source | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index 237bbb55..438efe52 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -68,7 +68,7 @@ import sys import jinja2 import yaml -from patacrep import files, Rx, utils +from patacrep import files, Rx from patacrep.errors import SBFileError, SharedError LOGGER = logging.getLogger(__name__) @@ -266,7 +266,7 @@ def process_content(content, config=None): content = [{'song': None}] for elem in content: if isinstance(elem, str): - elem = {'song': [elem]} + elem = {'song': elem} if isinstance(elem, dict): for keyword, argument in elem.items(): if keyword not in plugins: diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 18680442..56ed0205 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -78,6 +78,8 @@ def parse(keyword, argument, config): Return a list of Song() instances. """ contentlist = argument + if isinstance(contentlist, str): + contentlist = [contentlist] plugins = config['_song_plugins'] if '_langs' not in config: config['_langs'] = set() diff --git a/test/test_content/songs.source b/test/test_content/songs.source index dcd19323..65b1dd9d 100644 --- a/test/test_content/songs.source +++ b/test/test_content/songs.source @@ -1 +1,7 @@ -["exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file +- exsong.sg +- intersong.is +- jsonlist.json +- texfile.tex +- texsong.tsg +- song: chordpro.csg +- subdir/chordpro.csg \ No newline at end of file