Browse Source

include now supports yaml

pull/190/head
Oliverpool 9 years ago
parent
commit
9751e1136c
  1. 6
      patacrep/content/include.py
  2. 4
      test/test_content/include.control
  3. 2
      test/test_content/include.source

6
patacrep/content/include.py

@ -1,10 +1,10 @@
"""Include an external list of songs
This plugin provides keyword 'include', used to include an external list of
songs in JSON format.
songs in JSON or YAML format.
"""
import json
import yaml
import os
import logging
@ -62,7 +62,7 @@ def parse(keyword, config, argument):
filepath,
encoding=config['book']['encoding']
) as content_file:
new_content = json.load(content_file)
new_content = yaml.load(content_file)
except Exception as error: # pylint: disable=broad-except
new_contentlist.append_error(ContentError(
keyword="include",

4
test/test_content/include.control

@ -1,6 +1,6 @@
- exsong.sg
- chordpro.csg
- subdir/chordpro.csg
- exsong.sg
- chordpro.csg
- subdir/chordpro.csg
- subdir/chordpro.csg
- exsong.sg

2
test/test_content/include.source

@ -1,3 +1,3 @@
- include:
- custom_list.json
- include: custom_list.json
- include: custom_list.yaml
Loading…
Cancel
Save