Browse Source

Rename 'sorted' keyword to 'sort'

pull/190/head
Louis 9 years ago
parent
commit
5df09d1744
  1. 2
      examples/example-all.sb
  2. 2
      examples/example-all.yaml.sb
  3. 8
      patacrep/content/__init__.py
  4. 6
      patacrep/content/sort.py
  5. 2
      test/test_content/datadir/songs/custom_list.yaml
  6. 0
      test/test_content/datadir_sort/path1_title1_author1.csg
  7. 0
      test/test_content/datadir_sort/path1_title1_author2.csg
  8. 0
      test/test_content/datadir_sort/path1_title2_author1.csg
  9. 0
      test/test_content/datadir_sort/path1_title2_author2.csg
  10. 0
      test/test_content/datadir_sort/path2_title1_author1.csg
  11. 0
      test/test_content/datadir_sort/path2_title1_author2.csg
  12. 0
      test/test_content/datadir_sort/path2_title2_author1.csg
  13. 0
      test/test_content/datadir_sort/path2_title2_author2.csg
  14. 27
      test/test_content/sort.control
  15. 8
      test/test_content/sort.source
  16. 27
      test/test_content/sorted.control
  17. 4
      test/test_songbook/content.sb

2
examples/example-all.sb

@ -14,6 +14,6 @@
"sep" : ["and", "et"] "sep" : ["and", "et"]
}, },
"datadir" : ".", "datadir" : ".",
"content": [["sorted"]] "content": [["sort"]]
} }

2
examples/example-all.yaml.sb

@ -13,7 +13,7 @@ authors:
separators: separators:
- "and" - "and"
- "et" - "et"
content: {"sorted"} content: {"sort"}
template: template:
patacrep.tex: patacrep.tex:

8
patacrep/content/__init__.py

@ -19,7 +19,7 @@ met, the corresponding parser is called.
# Keyword examples # Keyword examples
- sorted - sort
- section* - section*
- cwd - cwd
@ -35,14 +35,14 @@ A parser returns a ContentList object (a list of instances of the ContentItem
class), defined in this module (or of subclasses of this class). class), defined in this module (or of subclasses of this class).
Example: When the following piece of content is met Example: When the following piece of content is met
sorted: sort:
key: ["author", "title"] key: ["author", "title"]
content: content:
- "a_song.sg" - "a_song.sg"
- "another_song.sg" - "another_song.sg"
the parser associated to keyword 'sorted' get the arguments: the parser associated to keyword 'sort' get the arguments:
- keyword = "sorted" - keyword = "sort"
- argument = { - argument = {
'key': ["author", "title"], 'key': ["author", "title"],
'content': ["a_song.sg", "another_song.sg"], 'content': ["a_song.sg", "another_song.sg"],

6
patacrep/content/sorted.py → patacrep/content/sort.py

@ -1,6 +1,6 @@
"""Sorted list of songs. """Sorted list of songs.
This plugin provides keyword 'sorted', used to include a sorted list of songs This plugin provides keyword 'sort', used to include a sorted list of songs
to a songbook. to a songbook.
""" """
@ -85,7 +85,7 @@ def parse(keyword, config, argument):
"""Return a sorted list of songs. """Return a sorted list of songs.
Arguments: Arguments:
- keyword: the string 'sorted'; - keyword: the string 'sort';
- config: the current songbook configuration dictionary; - config: the current songbook configuration dictionary;
- argument: a dict of: - argument: a dict of:
key: the list of the fields used to sort songs (e.g. "by", "album", "title") key: the list of the fields used to sort songs (e.g. "by", "album", "title")
@ -108,4 +108,4 @@ def parse(keyword, config, argument):
)) ))
return sorted(songlist, key=key_generator(sort)) return sorted(songlist, key=key_generator(sort))
CONTENT_PLUGINS = {'sorted': parse} CONTENT_PLUGINS = {'sort': parse}

2
test/test_content/datadir/songs/custom_list.yaml

@ -1,4 +1,4 @@
- sorted: - sort:
key: "title" key: "title"
content: content:
- exsong.sg - exsong.sg

0
test/test_content/datadir_sorted/path1_title1_author1.csg → test/test_content/datadir_sort/path1_title1_author1.csg

0
test/test_content/datadir_sorted/path1_title1_author2.csg → test/test_content/datadir_sort/path1_title1_author2.csg

0
test/test_content/datadir_sorted/path1_title2_author1.csg → test/test_content/datadir_sort/path1_title2_author1.csg

0
test/test_content/datadir_sorted/path1_title2_author2.csg → test/test_content/datadir_sort/path1_title2_author2.csg

0
test/test_content/datadir_sorted/path2_title1_author1.csg → test/test_content/datadir_sort/path2_title1_author1.csg

0
test/test_content/datadir_sorted/path2_title1_author2.csg → test/test_content/datadir_sort/path2_title1_author2.csg

0
test/test_content/datadir_sorted/path2_title2_author1.csg → test/test_content/datadir_sort/path2_title2_author1.csg

0
test/test_content/datadir_sorted/path2_title2_author2.csg → test/test_content/datadir_sort/path2_title2_author2.csg

27
test/test_content/sort.control

@ -0,0 +1,27 @@
- section{Title}
- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg"
- section{Author, Title}
- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg"
- section{Path, Title}
- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg"

8
test/test_content/sorted.source → test/test_content/sort.source

@ -1,15 +1,15 @@
- cwd: - cwd:
path: "datadir_sorted" path: "datadir_sort"
content: content:
- section: - section:
name: "Title" name: "Title"
- sorted: - sort:
key: title key: title
- section: - section:
name: "Author, Title" name: "Author, Title"
- sorted: - sort:
key: [by, title] key: [by, title]
- section: - section:
name: "Path, Title" name: "Path, Title"
- sorted: - sort:
key: [path, title] key: [path, title]

27
test/test_content/sorted.control

@ -1,27 +0,0 @@
- section{Title}
- "@TEST_FOLDER@/datadir_sorted/path1_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title2_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title2_author2.csg"
- section{Author, Title}
- "@TEST_FOLDER@/datadir_sorted/path1_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title2_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title2_author2.csg"
- section{Path, Title}
- "@TEST_FOLDER@/datadir_sorted/path1_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path1_title2_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title1_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title1_author2.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title2_author1.csg"
- "@TEST_FOLDER@/datadir_sorted/path2_title2_author2.csg"

4
test/test_songbook/content.sb

@ -9,7 +9,7 @@ chords:
content: content:
- section: Test of section - section: Test of section
- sorted: - sort:
- songsection: Test of song section - songsection: Test of song section
- cwd: - cwd:
# relative to sg file # relative to sg file
@ -22,4 +22,4 @@ content:
path: ../content path: ../content
content: content:
- tex: foo.tex - tex: foo.tex
- include: include.sbc - include: include.sbc

Loading…
Cancel
Save