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) return r'\{}{{{}}}'.format(self.keyword, self.name)
#pylint: disable=unused-argument #pylint: disable=unused-argument
def parse(keyword, argument, contentlist, config): def parse(keyword, argument, config):
"""Parse the contentlist. """Parse the contentlist.
Arguments: Arguments:
- keyword ("songsection" or "songchapter"): the section to use; - keyword ("songsection" or "songchapter"): the section to use;
- argument: unused; - argument: name of the section;
- contentlist: a list of one string, which is the name of the section;
- config: configuration dictionary of the current songbook. - config: configuration dictionary of the current songbook.
""" """
try: return ContentList([SongSection(keyword, argument)])
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])
CONTENT_PLUGINS = dict([ CONTENT_PLUGINS = dict([

12
test/test_content/songsection.source

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

2
test/test_songbook/content.sb

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

Loading…
Cancel
Save