Browse Source

Correction d'un bug dans l'interaction avec songbook-web

Les chaines etait passées comme des instances de str,
et les carnets produits étaient vides.
pull/42/head
Luthaf 11 years ago
parent
commit
afffdb19b1
  1. 13
      songbook_core/build.py
  2. 13
      songbook_core/errors.py

13
songbook_core/build.py

@ -114,10 +114,15 @@ class Songbook(object):
content = self.config["content"] content = self.config["content"]
self.config["content"] = [] self.config["content"] = []
for elem in content: for elem in content:
if isinstance(elem, unicode): if isinstance(elem, str) or isinstance(elem, unicode):
self.config["content"].append(("song", elem)) self.config["content"].append(("song", elem))
else: elif isinstance(elem, list):
self.config["content"].append((elem[0], elem[1])) self.config["content"].append((elem[0], elem[1]))
else:
raise errors.SBFileError(
"Syntax error: could not decode the content "
"of {0}".format(self.basename)
)
# Ensure self.config['authwords'] contains all entries # Ensure self.config['authwords'] contains all entries
for (key, value) in DEFAULT_AUTHWORDS.items(): for (key, value) in DEFAULT_AUTHWORDS.items():
@ -126,7 +131,7 @@ class Songbook(object):
def _parse_songs(self): def _parse_songs(self):
"""Parse content included in songbook.""" """Parse content included in songbook."""
self.contentlist = SongbookContent(self.config['datadir']) self.contentlist = SongbookContent(self.config['datadir'])
self.contentlist.append_list(self.config['content']) self.contentlist.append_list(self.config['content'])
def write_tex(self, output): def write_tex(self, output):
@ -149,7 +154,7 @@ class Songbook(object):
context['filename'] = output.name[:-4] context['filename'] = output.name[:-4]
self._set_songs_default(context) self._set_songs_default(context)
print(self.contentlist.content)
renderer.render_tex(output, context) renderer.render_tex(output, context)

13
songbook_core/errors.py

@ -10,6 +10,19 @@ class SongbookError(Exception):
""" """
pass pass
class SBFileError(SongbookError):
"""Error during songbook file decoding"""
def __init__(self, message=None):
super(SBFileError, self).__init__()
self.message = message
def __str__(self):
if self.message is None:
return str(self.original)
else:
return self.message
class TemplateError(SongbookError): class TemplateError(SongbookError):
"""Error during template generation""" """Error during template generation"""

Loading…
Cancel
Save