Browse Source

sorted is now in yaml

pull/190/head
Oliverpool 9 years ago
parent
commit
3f02240670
  1. 24
      patacrep/content/sorted.py
  2. 5
      test/test_content/sorted.control
  3. 5
      test/test_content/sorted.source
  4. 2
      test/test_songbook/content.sb

24
patacrep/content/sorted.py

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

5
test/test_content/sorted.control

@ -1 +1,4 @@
["chordpro.csg", "exsong.sg", "subdir/chordpro.csg", "texsong.tsg"]
[
"texsong.tsg", "chordpro.csg", "subdir/chordpro.csg", "exsong.sg",
"exsong.sg", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"
]

5
test/test_content/sorted.source

@ -1 +1,4 @@
[["sorted(fullpath)"]]
- sorted:
key: "@title"
- sorted:
key: [by, "@title"]

2
test/test_songbook/content.sb

@ -8,7 +8,7 @@ chords:
content:
- section: Test of section
- ["sorted"]
- sorted:
- songsection: Test of song section
- cwd:
path: content_datadir/content

Loading…
Cancel
Save