Browse Source

Ajout d'un message en cas de clef de tri incorrecte

pull/47/head
Louis 10 years ago
parent
commit
2e12374e27
  1. 15
      songbook_core/content/sorted.py

15
songbook_core/content/sorted.py

@ -8,10 +8,14 @@ to a songbook.
""" """
import locale import locale
import logging
import os
from songbook_core.content import ContentError from songbook_core.content import ContentError
from songbook_core.content.song import OnlySongsError, process_songs from songbook_core.content.song import OnlySongsError, process_songs
LOGGER = logging.getLogger(__name__)
DEFAULT_SORT = ['by', 'album', '@title'] DEFAULT_SORT = ['by', 'album', '@title']
def normalize_string(string): def normalize_string(string):
@ -49,7 +53,16 @@ def key_generator(sort):
elif key == "by": elif key == "by":
field = song.authors field = song.authors
else: else:
field = song.args.get(key, "") try:
field = song.args[key]
except KeyError:
LOGGER.debug(
"Ignoring non-existent key '{}' for song {}.".format(
key,
os.path.relpath(song.path),
)
)
field = ""
songkey.append(normalize_field(field)) songkey.append(normalize_field(field))
return songkey return songkey
return ordered_song_keys return ordered_song_keys

Loading…
Cancel
Save