|
@ -67,23 +67,25 @@ def key_generator(sort): |
|
|
return ordered_song_keys |
|
|
return ordered_song_keys |
|
|
|
|
|
|
|
|
#pylint: disable=unused-argument |
|
|
#pylint: disable=unused-argument |
|
|
def parse(keyword, config, argument, contentlist): |
|
|
def parse(keyword, config, argument): |
|
|
"""Return a sorted list of songs contained in 'contentlist'. |
|
|
"""Return a sorted list of songs. |
|
|
|
|
|
|
|
|
Arguments: |
|
|
Arguments: |
|
|
- keyword: the string 'sorted'; |
|
|
- keyword: the string 'sorted'; |
|
|
- config: the current songbook configuration dictionary; |
|
|
- config: the current songbook configuration dictionary; |
|
|
- argument: the list of the fields used to sort songs, as strings |
|
|
- argument: a dict of: |
|
|
separated by commas (e.g. "by, album, @title"); |
|
|
key: the list of the fields used to sort songs (e.g. "by", "album", "@title") |
|
|
- contentlist: the list of content to be sorted. If this content |
|
|
a minus mean reverse order: "-@title" |
|
|
contain something else than a song, an exception is raised. |
|
|
content: content to be sorted. If this content |
|
|
|
|
|
contain something else than a song, an exception is raised. |
|
|
""" |
|
|
""" |
|
|
if argument: |
|
|
if argument is None: |
|
|
sort = [key.strip() for key in argument.split(",")] |
|
|
argument = {} |
|
|
else: |
|
|
sort = argument.get('key', DEFAULT_SORT) |
|
|
sort = DEFAULT_SORT |
|
|
if isinstance(sort, str): |
|
|
|
|
|
sort = [sort] |
|
|
try: |
|
|
try: |
|
|
songlist = process_content(contentlist, config) |
|
|
songlist = process_content(argument.get('content'), config) |
|
|
except OnlySongsError as error: |
|
|
except OnlySongsError as error: |
|
|
return EmptyContentList(errors=[ContentError(keyword, ( |
|
|
return EmptyContentList(errors=[ContentError(keyword, ( |
|
|
"Content list of this keyword can be only songs (or content " |
|
|
"Content list of this keyword can be only songs (or content " |
|
|