Browse Source

include now supports yaml

pull/190/head
Oliverpool 9 years ago
parent
commit
9751e1136c
  1. 6
      patacrep/content/include.py
  2. 2
      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 """Include an external list of songs
This plugin provides keyword 'include', used to include an external list of 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 os
import logging import logging
@ -62,7 +62,7 @@ def parse(keyword, config, argument):
filepath, filepath,
encoding=config['book']['encoding'] encoding=config['book']['encoding']
) as content_file: ) as content_file:
new_content = json.load(content_file) new_content = yaml.load(content_file)
except Exception as error: # pylint: disable=broad-except except Exception as error: # pylint: disable=broad-except
new_contentlist.append_error(ContentError( new_contentlist.append_error(ContentError(
keyword="include", keyword="include",

2
test/test_content/include.control

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

2
test/test_content/include.source

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