Browse Source

songsection is now yaml compatible

pull/190/head
Oliverpool 9 years ago
parent
commit
15e4a578ce
  1. 15
      patacrep/content/songsection.py
  2. 12
      test/test_content/songsection.source
  3. 2
      test/test_songbook/content.sb

15
patacrep/content/songsection.py

@ -20,24 +20,15 @@ class SongSection(ContentItem):
return r'\{}{{{}}}'.format(self.keyword, self.name)
#pylint: disable=unused-argument
def parse(keyword, argument, contentlist, config):
def parse(keyword, argument, config):
"""Parse the contentlist.
Arguments:
- keyword ("songsection" or "songchapter"): the section to use;
- argument: unused;
- contentlist: a list of one string, which is the name of the section;
- argument: name of the section;
- config: configuration dictionary of the current songbook.
"""
try:
if (keyword not in KEYWORDS) and (len(contentlist) != 1):
raise ContentError(
keyword,
"Starred section names must have exactly one argument.",
)
return ContentList([SongSection(keyword, contentlist[0])])
except ContentError as error:
return EmptyContentList(errors=[error])
return ContentList([SongSection(keyword, argument)])
CONTENT_PLUGINS = dict([

12
test/test_content/songsection.source

@ -1,6 +1,6 @@
[["songsection", "Traditional"],
"exsong.sg",
["songchapter", "English"],
"texsong.tsg",
"chordpro.csg",
"exsong.sg"]
- songsection: Traditional
- "exsong.sg"
- songchapter: English
- "texsong.tsg"
- "chordpro.csg"
- "exsong.sg"

2
test/test_songbook/content.sb

@ -9,7 +9,7 @@ chords:
content:
- section: Test of section
- ["sorted"]
- ["songsection", "Test of song section"]
- songsection: Test of song section
- ["cwd(content_datadir/content)",
"song.csg", "song.tsg",
["tex", "foo.tex"]

Loading…
Cancel
Save