From 7556c99703e1c34fa13781aba549b30bb74e65f1 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:33:25 +0100 Subject: [PATCH] Replace json parser by yaml --- examples/example-all.yaml.sb | 17 +++++++++++++++++ patacrep/songbook/__main__.py | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 examples/example-all.yaml.sb diff --git a/examples/example-all.yaml.sb b/examples/example-all.yaml.sb new file mode 100644 index 00000000..3a167565 --- /dev/null +++ b/examples/example-all.yaml.sb @@ -0,0 +1,17 @@ +bookoptions: + - "diagram" + - "repeatchords" + - "lilypond" + - "pictures" +booktype: "chorded" +datadir: "." +template: "patacrep.tex" +lang: "fr" +encoding: "utf8" +authwords: + sep: + - "and" + - "et" +content: + - + - "sorted" \ No newline at end of file diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index cc56311b..b972b04c 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -1,7 +1,7 @@ """Command line tool to compile songbooks using the songbook library.""" import argparse -import json +import yaml import locale import logging import os.path @@ -135,13 +135,13 @@ def main(): try: with patacrep.encoding.open_read(songbook_path) as songbook_file: - songbook = json.load(songbook_file) + songbook = yaml.load(songbook_file) if 'encoding' in songbook: with patacrep.encoding.open_read( songbook_path, encoding=songbook['encoding'] ) as songbook_file: - songbook = json.load(songbook_file) + songbook = yaml.load(songbook_file) except Exception as error: # pylint: disable=broad-except LOGGER.error(error) LOGGER.error("Error while loading file '{}'.".format(songbook_path))