Browse Source

[WIP] Managing titleprefixwords

pull/47/head
Louis 11 years ago
parent
commit
b7db9bcb6d
  1. 18
      songbook_core/build.py
  2. 2
      songbook_core/content/song.py
  3. 6
      songbook_core/songs.py

18
songbook_core/build.py

@ -57,24 +57,15 @@ class Songbook(object):
'lang': 'english',
'sort': [u"by", u"album", u"@title"],
'content': None,
'titleprefixwords': [],
}
self._parse_raw(raw_songbook)
@staticmethod
def _set_songs_default(config):
"""Set the default values for the Song() class.
Argument:
- config : a dictionary containing the configuration
TODO Move this function elsewhere
"""
return
Song.sort = config['sort']
if 'titleprefixwords' in config:
Song.prefixes = config['titleprefixwords']
else:
Song.prefixes = []
def __TODO(self):
Song.authwords['after'] = [
re.compile(r"^.*%s\b(.*)" % after)
for after
@ -142,7 +133,6 @@ class Songbook(object):
context['content'] = self.contentlist
context['filename'] = output.name[:-4]
self._set_songs_default(context)
renderer.render_tex(output, context)

2
songbook_core/content/song.py

@ -54,7 +54,7 @@ def parse(keyword, config, *arguments):
for songdir in [os.path.join(d, 'songs') for d in config['datadir']]:
for filename in glob.iglob(os.path.join(songdir, elem)):
LOGGER.debug('Parsing file "{}"'.format(filename))
song = SongRenderer(filename)
song = SongRenderer(filename, config)
songlist.append(song)
config["languages"].update(song.languages)
if len(songlist) > before:

6
songbook_core/songs.py

@ -16,12 +16,10 @@ class Song(object):
#: Ordre de tri
sort = []
#: Préfixes à ignorer pour le tri par titres
prefixes = []
#: Dictionnaire des options pour le traitement des auteurs
authwords = {"after": [], "ignore": [], "sep": []}
def __init__(self, filename):
def __init__(self, filename, config):
# Data extraction from the song with plastex
data = parsetex(filename)
self.titles = data['titles']
@ -29,7 +27,7 @@ class Song(object):
locale.strxfrm(
unprefixed_title(
unidecode(unicode(title, "utf-8")),
self.prefixes
config['titleprefixwords']
)
)
for title

Loading…
Cancel
Save