summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam@sotk.co.uk>2016-10-06 22:01:54 +0100
committerAdam Coldrick <adam@sotk.co.uk>2016-10-06 22:35:24 +0100
commitdd9f0de2bc8aadb57f20ce998fcdefbda91f59b6 (patch)
treee9eccb2aeaa5648056bfaa1491d2c1e8e53ec727
parentc06dc5acf0e712827ca52d6611c3b13dab6744fd (diff)
downloadlorry-dd9f0de2bc8aadb57f20ce998fcdefbda91f59b6.tar.gz
Add support for YAML lorries
If parsing the lorry as YAML fails, we attempt to parse it as JSON before giving up completely. Change-Id: I7e3502f5ae9c32e10d63047e5f280bfe1d7e52dc
-rwxr-xr-xlorry10
-rw-r--r--test.lorry26
2 files changed, 18 insertions, 18 deletions
diff --git a/lorry b/lorry
index 6bca47a..3b9f471 100755
--- a/lorry
+++ b/lorry
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (C) 2013-2015 Codethink Limited
+# Copyright (C) 2013-2016 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,6 +27,8 @@ import shutil
import traceback
import functools
+import yaml
+
__version__ = '0.0'
lorry_path = os.path.realpath(__file__)
@@ -107,7 +109,11 @@ class Lorry(cliapp.Application):
for arg in args:
self.progress('Processing spec file %s' % arg)
with open(arg) as f:
- specs = json.load(f)
+ try:
+ specs = yaml.safe_load(f)
+ except yaml.YAMLError:
+ f.seek(0)
+ specs = json.load(f)
for name in sorted(specs.keys()):
self.progress('Getting: %s' % name)
try:
diff --git a/test.lorry b/test.lorry
index 57f21cc..c7b933e 100644
--- a/test.lorry
+++ b/test.lorry
@@ -1,16 +1,10 @@
-{
- "gawk": {
- "type": "git",
- "url": "git://git.savannah.gnu.org/gawk.git"
- },
- "binutils": {
- "type": "bzr",
- "branches": {
- "trunk": "lp:binutils"
- }
- },
- "bc": {
- "type": "tarball",
- "url": "http://ftp.gnu.org/gnu/bc/bc-1.06.tar.gz"
- }
-}
+gawk:
+ type: git
+ url: git://git.savannah.gnu.org/gawk.git
+binutils:
+ type: bzr
+ branches:
+ trunk: lp:binutils
+bc:
+ type: tarball
+ url: http://ftp.gnu.org/gnu/bc/bc-1.06.tar.gz