diff options
author | Adam Coldrick <adam@sotk.co.uk> | 2016-10-06 22:01:54 +0100 |
---|---|---|
committer | Adam Coldrick <adam@sotk.co.uk> | 2016-10-06 22:35:24 +0100 |
commit | dd9f0de2bc8aadb57f20ce998fcdefbda91f59b6 (patch) | |
tree | e9eccb2aeaa5648056bfaa1491d2c1e8e53ec727 | |
parent | c06dc5acf0e712827ca52d6611c3b13dab6744fd (diff) | |
download | lorry-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-x | lorry | 10 | ||||
-rw-r--r-- | test.lorry | 26 |
2 files changed, 18 insertions, 18 deletions
@@ -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: @@ -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 |