|
@ -41,31 +41,32 @@ class Songbook(object): |
|
|
# Default values: will be updated while parsing raw_songbook |
|
|
# Default values: will be updated while parsing raw_songbook |
|
|
self.config = { |
|
|
self.config = { |
|
|
'template': "default.tex", |
|
|
'template': "default.tex", |
|
|
'titleprefixwords': [], |
|
|
'lang': 'english', |
|
|
'authwords': {}, |
|
|
|
|
|
'lang': 'french', |
|
|
|
|
|
'sort': [u"by", u"album", u"@title"], |
|
|
'sort': [u"by", u"album", u"@title"], |
|
|
'content': None, |
|
|
'content': None, |
|
|
'datadir': os.path.abspath('.'), |
|
|
'datadir': os.path.abspath('.'), |
|
|
} |
|
|
} |
|
|
self.songslist = None |
|
|
self.songslist = None |
|
|
self._parse(raw_songbook) |
|
|
self._parse(raw_songbook) |
|
|
self._set_songs_default() |
|
|
|
|
|
|
|
|
|
|
|
def _set_songs_default(self): |
|
|
def _set_songs_default(self, config): |
|
|
"""Set the default values for the Song() class.""" |
|
|
"""Set the default values for the Song() class. |
|
|
Song.sort = self.config['sort'] |
|
|
|
|
|
Song.prefixes = self.config['titleprefixwords'] |
|
|
Argument: |
|
|
|
|
|
- config : a dictionary containing the configuration |
|
|
|
|
|
""" |
|
|
|
|
|
Song.sort = config['sort'] |
|
|
|
|
|
Song.prefixes = config['titleprefixwords'] |
|
|
Song.authwords['after'] = [ |
|
|
Song.authwords['after'] = [ |
|
|
re.compile(r"^.*%s\b(.*)" % after) |
|
|
re.compile(r"^.*%s\b(.*)" % after) |
|
|
for after |
|
|
for after |
|
|
in self.config['authwords']["after"] |
|
|
in config['authwords']["after"] |
|
|
] |
|
|
] |
|
|
Song.authwords['ignore'] = self.config['authwords']['ignore'] |
|
|
Song.authwords['ignore'] = config['authwords']['ignore'] |
|
|
Song.authwords['sep'] = [ |
|
|
Song.authwords['sep'] = [ |
|
|
re.compile(r"^(.*)%s (.*)$" % sep) |
|
|
re.compile(r"^(.*)%s (.*)$" % sep) |
|
|
for sep in ([ |
|
|
for sep in ([ |
|
|
" %s" % sep for sep in self.config['authwords']["sep"] |
|
|
" %s" % sep for sep in config['authwords']["sep"] |
|
|
] + [',']) |
|
|
] + [',']) |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
@ -112,12 +113,13 @@ class Songbook(object): |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
context = renderer.get_variables() |
|
|
context = renderer.get_variables() |
|
|
|
|
|
|
|
|
context.update(self.config) |
|
|
context.update(self.config) |
|
|
context['titleprefixkeys'] = ["after", "sep", "ignore"] |
|
|
context['titleprefixkeys'] = ["after", "sep", "ignore"] |
|
|
context['songlist'] = self.songslist |
|
|
context['songlist'] = self.songslist |
|
|
context['filename'] = output.name[:-4] |
|
|
context['filename'] = output.name[:-4] |
|
|
|
|
|
|
|
|
|
|
|
self._set_songs_default(context) |
|
|
|
|
|
|
|
|
renderer.render_tex(output, context) |
|
|
renderer.render_tex(output, context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|