Browse Source

song plugin support argument

pull/190/head
Oliverpool 9 years ago
parent
commit
0481ce5962
  1. 4
      patacrep/content/__init__.py
  2. 2
      patacrep/content/song.py
  3. 8
      test/test_content/songs.source

4
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:

2
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()

8
test/test_content/songs.source

@ -1 +1,7 @@
["exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"]
- exsong.sg
- intersong.is
- jsonlist.json
- texfile.tex
- texsong.tsg
- song: chordpro.csg
- subdir/chordpro.csg
Loading…
Cancel
Save