Browse Source

Replace json parser by yaml

pull/183/head
Oliverpool 9 years ago
parent
commit
7556c99703
  1. 17
      examples/example-all.yaml.sb
  2. 6
      patacrep/songbook/__main__.py

17
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"

6
patacrep/songbook/__main__.py

@ -1,7 +1,7 @@
"""Command line tool to compile songbooks using the songbook library.""" """Command line tool to compile songbooks using the songbook library."""
import argparse import argparse
import json import yaml
import locale import locale
import logging import logging
import os.path import os.path
@ -135,13 +135,13 @@ def main():
try: try:
with patacrep.encoding.open_read(songbook_path) as songbook_file: with patacrep.encoding.open_read(songbook_path) as songbook_file:
songbook = json.load(songbook_file) songbook = yaml.load(songbook_file)
if 'encoding' in songbook: if 'encoding' in songbook:
with patacrep.encoding.open_read( with patacrep.encoding.open_read(
songbook_path, songbook_path,
encoding=songbook['encoding'] encoding=songbook['encoding']
) as songbook_file: ) as songbook_file:
songbook = json.load(songbook_file) songbook = yaml.load(songbook_file)
except Exception as error: # pylint: disable=broad-except except Exception as error: # pylint: disable=broad-except
LOGGER.error(error) LOGGER.error(error)
LOGGER.error("Error while loading file '{}'.".format(songbook_path)) LOGGER.error("Error while loading file '{}'.".format(songbook_path))

Loading…
Cancel
Save