From dd9f0de2bc8aadb57f20ce998fcdefbda91f59b6 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 6 Oct 2016 22:01:54 +0100 Subject: 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 --- lorry | 10 ++++++++-- test.lorry | 26 ++++++++++---------------- 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 -- cgit v1.2.1