From a8d30277932099dcae31f99d3fbd531f74eb0249 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 21 Jan 2013 18:01:19 +0000 Subject: Move OrderedDict and json loading to morphlib.util This way everyone who needs json or an OrderedDict doesn't have to worry about it. Currently morph2 is the only one that needs this complex behaviour, other users of the json module don't need object_pairs_hook. --- morphlib/morph2.py | 11 +---------- morphlib/util.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 4fdf7ba4..9e5be2e6 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -17,16 +17,7 @@ import copy import re -# It is intentional that if collections does not have OrderedDict that -# simplejson is also used in preference to json, as OrderedDict became -# a member of collections in the same release json got its object_pairs_hook -try: # pragma: no cover - from collections import OrderedDict - import json -except ImportError: # pragma: no cover - from ordereddict import OrderedDict - import simplejson as json - +from morphlib.util import OrderedDict, json class Morphology(object): diff --git a/morphlib/util.py b/morphlib/util.py index 100f4b6b..e171714a 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2012 Codethink Limited +# Copyright (C) 2011-2013 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 @@ -20,6 +20,16 @@ import morphlib '''Utility functions for morph.''' +# It is intentional that if collections does not have OrderedDict that +# simplejson is also used in preference to json, as OrderedDict became +# a member of collections in the same release json got its object_pairs_hook +try: # pragma: no cover + from collections import OrderedDict + import json +except ImportError: # pragma: no cover + from ordereddict import OrderedDict + import simplejson as json + try: from multiprocessing import cpu_count except NotImplementedError: # pragma: no cover -- cgit v1.2.1 From 7ef9cb8922bd933ae8ee58cb24a2b38844a0e629 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 18 Jan 2013 16:18:20 +0000 Subject: Parse as YAML if not valid JSON Tests are currently broken, one because invalid JSON can be valid YAML, and coverage is incomplete. --- morphlib/__init__.py | 3 +- morphlib/morph2.py | 26 +++++++-- morphlib/morphologyfactory.py | 6 ++- morphlib/yamlparse.py | 119 ++++++++++++++++++++++++++++++++++++++++++ run-bootstrap-in-chroot | 2 +- 5 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 morphlib/yamlparse.py diff --git a/morphlib/__init__.py b/morphlib/__init__.py index 213241d8..5730d41e 100644 --- a/morphlib/__init__.py +++ b/morphlib/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2012 Codethink Limited +# Copyright (C) 2011-2013 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 @@ -56,5 +56,6 @@ import stagingarea import stopwatch import tempdir import util +import yamlparse import app # this needs to be last diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 9e5be2e6..edf7bb31 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -17,6 +17,7 @@ import copy import re +import morphlib from morphlib.util import OrderedDict, json class Morphology(object): @@ -52,8 +53,26 @@ class Morphology(object): ] } + @staticmethod + def _load_json(text): + return json.loads(text, object_pairs_hook=OrderedDict) + + @staticmethod + def _dump_json(obj, f): + text = json.dumps(obj, indent=4) + text = re.sub(" \n", "\n", text) + f.write(text) + f.write('\n') + def __init__(self, text): - self._dict = json.loads(text, object_pairs_hook=OrderedDict) + # Load as JSON first, then try YAML, so morphologies + # that read as JSON are dumped as JSON, likewise with YAML. + try: + self._dict = self._load_json(text) + self._dumper = self._dump_json + except Exception, e: + self._dict = morphlib.yamlparse.load(text) + self._dumper = morphlib.yamlparse.dump self._set_defaults() self._validate_children() @@ -156,7 +175,4 @@ class Morphology(object): value = self[key] if value and key[0] != '_': as_dict[key] = value - text = json.dumps(as_dict, indent=4) - text = re.sub(" \n", "\n", text) - f.write(text) - f.write('\n') + self._dumper(as_dict, f) diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index a219ed9b..261dc908 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 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 @@ -13,6 +13,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import yaml + import morphlib import cliapp @@ -81,7 +83,7 @@ class MorphologyFactory(object): try: morphology = morphlib.morph2.Morphology(text) - except ValueError as e: + except yaml.YAMLError as e: raise morphlib.Error("Error parsing %s: %s" % (filename, str(e))) diff --git a/morphlib/yamlparse.py b/morphlib/yamlparse.py new file mode 100644 index 00000000..7f8b00e5 --- /dev/null +++ b/morphlib/yamlparse.py @@ -0,0 +1,119 @@ +# Copyright (C) 2013 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import yaml +import yaml.constructor + +from morphlib.util import OrderedDict + +class OrderedDictYAMLLoader(yaml.Loader): + """A YAML loader that loads mappings into ordered dictionaries. + + When YAML is loaded with this Loader, it loads mappings as ordered + dictionaries, so the order the keys were written in is maintained. + + When combined with the OrderedDictYAMLDumper, this allows yaml documents + to be written out in a similar format to they were read. + + """ + + def __init__(self, *args, **kwargs): + yaml.Loader.__init__(self, *args, **kwargs) + + # When YAML encounters a mapping (which YAML identifies with + # the given tag), it will use construct_yaml_map to read it as + # an OrderedDict. + self.add_constructor(u'tag:yaml.org,2002:map', + type(self).construct_yaml_map) + + def construct_yaml_map(self, node): + data = OrderedDict() + yield data + value = self.construct_mapping(node) + data.update(value) + + def construct_mapping(self, node, deep=False): + if isinstance(node, yaml.MappingNode): + self.flatten_mapping(node) + else: + raise yaml.constructor.ConstructorError( + None, None, + 'expected a mapping node, but found %s' % node.id, + node.start_mark) + + mapping = OrderedDict() + for key_node, value_node in node.value: + key = self.construct_object(key_node, deep=deep) + try: + hash(key) + except TypeError, exc: + raise yaml.constructor.ConstructorError( + 'while constructing a mapping', node.start_mark, + 'found unacceptable key (%s)' % exc, key_node.start_mark) + value = self.construct_object(value_node, deep=deep) + mapping[key] = value + return mapping + +class OrderedDictYAMLDumper(yaml.Dumper): + """A YAML dumper that will dump OrderedDicts as mappings. + + When YAML is dumped with this Dumper, it dumps OrderedDicts as + mappings, preserving the key order, so the order the keys were + written in is maintained. + + When combined with the OrderedDictYAMLDumper, this allows yaml documents + to be written out in a similar format to they were read. + + """ + + def __init__(self, *args, **kwargs): + yaml.Dumper.__init__(self, *args, **kwargs) + + # When YAML sees an OrderedDict, use represent_ordered_dict to dump it + self.add_representer(OrderedDict, + type(self).represent_ordered_dict) + + def represent_ordered_dict(self, odict): + return self.represent_ordered_mapping(u'tag:yaml.org,2002:map', odict) + + def represent_ordered_mapping(self, tag, omap): + value = [] + node = yaml.MappingNode(tag, value) + if self.alias_key is not None: + self.represented_objects[self.alias_key] = node + best_style = True + for item_key, item_value in omap.iteritems(): + node_key = self.represent_data(item_key) + node_value = self.represent_data(item_value) + if not (isinstance(node_key, yaml.ScalarNode) and + not node_key.style): + best_style = False # pragma: no cover + if not (isinstance(node_value, yaml.ScalarNode) and + not node_value.style): + best_style = False # pragma: no cover + value.append((node_key, node_value)) + if self.default_flow_style is not None: + node.flow_style = self.default_flow_style + else: + node.flow_style = best_style # pragma: no cover + return node + +def load(*args, **kwargs): + return yaml.load(Loader=OrderedDictYAMLLoader, *args, **kwargs) + +def dump(*args, **kwargs): + if 'default_flow_style' not in kwargs: + kwargs['default_flow_style'] = False + return yaml.dump(Dumper=OrderedDictYAMLDumper, *args, **kwargs) diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot index 20a67c5a..fbe1e9f5 100755 --- a/run-bootstrap-in-chroot +++ b/run-bootstrap-in-chroot @@ -128,7 +128,7 @@ if ! "$snapshot" || ! has_pass pass1a; then EXTRAPACKAGES="build-essential,gawk,bison,flex,python,autoconf" EXTRAPACKAGES="$EXTRAPACKAGES,autopoint,automake,gettext,libtool" EXTRAPACKAGES="$EXTRAPACKAGES,help2man,texinfo,sudo,ccache,gperf" - EXTRAPACKAGES="$EXTRAPACKAGES,python-pip,python-simplejson" + EXTRAPACKAGES="$EXTRAPACKAGES,python-pip,python-simplejson,python-yaml" EXTRAARGS= if [ -n $ARCH]; then -- cgit v1.2.1 From 3f19b84e03c3452c54f18c1a0ccc6008c6478a99 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 18 Jan 2013 16:37:17 +0000 Subject: Fix tests Invalid text changed to be something that doesn't parse as YAML either, and catch convert the YAMLError to the expected exception. Ideally there wouldn't be any `#pragma: no cover`s, but I could not trigger these code paths. --- morphlib/morph2_tests.py | 19 +++++++++- morphlib/morphologyfactory_tests.py | 6 ++-- morphlib/yamlparse_tests.py | 69 +++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 morphlib/yamlparse_tests.py diff --git a/morphlib/morph2_tests.py b/morphlib/morph2_tests.py index 756873a0..34df4657 100644 --- a/morphlib/morph2_tests.py +++ b/morphlib/morph2_tests.py @@ -22,7 +22,7 @@ from morphlib.morph2 import Morphology class MorphologyTests(unittest.TestCase): - def test_parses_simple_chunk(self): + def test_parses_simple_json_chunk(self): m = Morphology(''' { "name": "foo", @@ -41,6 +41,23 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(m['max-jobs'], None) self.assertEqual(m['chunks'], []) + def test_parses_simple_yaml_chunk(self): + m = Morphology(''' + name: foo + kind: chunk + build-system: manual + ''') + + self.assertEqual(m['name'], 'foo') + self.assertEqual(m['kind'], 'chunk') + self.assertEqual(m['build-system'], 'manual') + self.assertEqual(m['configure-commands'], None) + self.assertEqual(m['build-commands'], None) + self.assertEqual(m['test-commands'], None) + self.assertEqual(m['install-commands'], None) + self.assertEqual(m['max-jobs'], None) + self.assertEqual(m['chunks'], []) + def test_sets_stratum_chunks_repo_and_morph_from_name(self): m = Morphology(''' { diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index b8c89d2a..56c6fc57 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 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 @@ -65,9 +65,7 @@ class FakeLocalRepo(object): "system-kind": "%(system_kind)s", "arch": "%(arch)s" }''', - 'parse-error.morph': '''{ - "name" - }''', + 'parse-error.morph': '''{ "name"''', } def __init__(self): diff --git a/morphlib/yamlparse_tests.py b/morphlib/yamlparse_tests.py new file mode 100644 index 00000000..cb658e15 --- /dev/null +++ b/morphlib/yamlparse_tests.py @@ -0,0 +1,69 @@ +# Copyright (C) 2013 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import unittest + +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict +import yaml + +import morphlib.yamlparse as yamlparse + + +class YAMLParseTests(unittest.TestCase): + + example_text = '''\ +name: foo +kind: chunk +build-system: manual +''' + + example_dict = OrderedDict([ + ('name', 'foo'), + ('kind', 'chunk'), + ('build-system', 'manual'), + ]) + + def test_loads_as_ordered_dict(self): + m = yamlparse.load(self.example_text) + self.assertEqual(type(m), OrderedDict) + + def test_dumps_ordered_dicts(self): + self.assertEqual(self.example_text, + yamlparse.dump(self.example_dict)) + + def test_non_map_raises(self): + incorrect_type = '''\ +!!map +- foo +- bar +''' + self.assertRaises(yaml.YAMLError, yamlparse.load, incorrect_type) + + def test_complex_key_fails_KNOWNFAILURE(self): + complex_key = '? { foo: bar, baz: qux }: True' + self.assertRaises(yaml.YAMLError, yamlparse.load, complex_key) + + def test_represents_non_scalar_nodes(self): + self.assertTrue( + yamlparse.dump( + { + ('a', 'b'): { + "foo": 1, + "bar": 2, + } + }, default_flow_style=None)) -- cgit v1.2.1 From 8c34d1e9d46b6802d8723f9d151019fe8a7c3250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Tue, 22 Jan 2013 16:28:09 +0000 Subject: Change build tests to use YAML morphologies --- tests.as-root/disk-builds-rootfs-and-kernel.script | 4 +- .../rootfs-tarball-builds-rootfs-and-kernel.script | 2 +- tests.as-root/setup | 144 ++++++++------------- tests.as-root/tarball-image-is-sensible.setup | 4 +- tests.as-root/target-disk-too-small.script | 6 +- 5 files changed, 64 insertions(+), 96 deletions(-) diff --git a/tests.as-root/disk-builds-rootfs-and-kernel.script b/tests.as-root/disk-builds-rootfs-and-kernel.script index c11c246f..2eb57743 100755 --- a/tests.as-root/disk-builds-rootfs-and-kernel.script +++ b/tests.as-root/disk-builds-rootfs-and-kernel.script @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012,2013 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 @@ -25,7 +25,7 @@ set -eu cache="$DATADIR/cache/artifacts" cd "$DATADIR/morphs" -sed -e 's/"system-kind": "syslinux-disk"/"system-kind": "disk"/' \ +sed -e 's/system-kind: syslinux-disk/system-kind: disk/' \ -i linux-system.morph git add linux-system.morph git commit --quiet -m "Build rootfs tarball system" diff --git a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script index c6179aaf..856d3488 100755 --- a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script +++ b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script @@ -29,7 +29,7 @@ cache="$DATADIR/cache/artifacts" arch=$(uname -m) cd "$DATADIR/morphs" -sed -e 's/"system-kind": "syslinux-disk"/"system-kind": "rootfs-tarball"/' \ +sed -e 's/system-kind: syslinux-disk/system-kind: rootfs-tarball/' \ -i linux-system.morph git add linux-system.morph git commit --quiet -m "Build rootfs tarball system" diff --git a/tests.as-root/setup b/tests.as-root/setup index d3ba7ef4..285a3143 100755 --- a/tests.as-root/setup +++ b/tests.as-root/setup @@ -10,7 +10,7 @@ # The stratum repository contains a single branch, "master", with a # stratum and a system morphology that include the chunk above. # -# Copyright (C) 2011, 2012 Codethink Limited +# Copyright (C) 2011, 2012, 2013 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 @@ -62,19 +62,15 @@ EOF git add hello.c cat < hello.morph -{ - "name": "hello", - "kind": "chunk", - "build-system": "dummy", - "build-commands": [ - "gcc -o hello hello.c" - ], - "install-commands": [ - "install -d \\"\$DESTDIR\\"/etc", - "install -d \\"\$DESTDIR\\"/bin", - "install hello \\"\$DESTDIR\\"/bin/hello" - ] -} +name: hello +kind: chunk +build-system: dummy +build-commands: + - gcc -o hello hello.c +install-commands: + - install -d "\$DESTDIR"/etc + - install -d "\$DESTDIR"/bin + - install hello "\$DESTDIR"/bin/hello EOF git add hello.morph @@ -92,82 +88,57 @@ cd "$morphsrepo" git init --quiet cat < hello-stratum.morph -{ - "name": "hello-stratum", - "kind": "stratum", - "chunks": [ - { - "name": "hello", - "repo": "test:chunk-repo", - "ref": "farrokh", - "build-depends": [] - } - ] -} +name: hello-stratum +kind: stratum +chunks: + - name: hello + repo: test:chunk-repo + ref: farrokh + build-depends: [] EOF git add hello-stratum.morph cat < hello-system.morph -{ - "name": "hello-system", - "kind": "system", - "system-kind": "syslinux-disk", - "arch": "$(uname -m)", - "disk-size": "1G", - "strata": [ - { - "morph": "hello-stratum", - "repo": "test:morphs", - "ref": "master" - } - ] -} +name: hello-system +kind: system +system-kind: syslinux-disk +arch: `uname -m` +disk-size: 1G +strata: + - morph: hello-stratum + repo: test:morphs + ref: master EOF git add hello-system.morph cat < linux-stratum.morph -{ - "name": "linux-stratum", - "kind": "stratum", - "build-depends": [ - { - "morph": "hello-stratum", - "repo": "test:morphs", - "ref": "master" - } - ], - "chunks": [ - { - "name": "linux", - "repo": "test:kernel-repo", - "ref": "master", - "build-depends": [] - } - ] -} +name: linux-stratum +kind: stratum +build-depends: + - morph: hello-stratum + repo: test:morphs + ref: master +chunks: + - name: linux + repo: test:kernel-repo + ref: master + build-depends: [] EOF git add linux-stratum.morph cat < linux-system.morph -{ - "name": "linux-system", - "kind": "system", - "system-kind": "syslinux-disk", - "arch": "$(uname -m)", - "disk-size": "1G", - "strata": [ - { - "morph": "hello-stratum", - "repo": "test:morphs", - "ref": "master" - }, - { - "morph": "linux-stratum", - "repo": "test:morphs", - "ref": "master" - } - ] -} +name: linux-system +kind: system +system-kind: syslinux-disk +arch: `uname -m` +disk-size: 1G +strata: + - morph: hello-stratum + repo: test:morphs + ref: master + - morph: linux-stratum + repo: test:morphs + ref: master EOF git add linux-system.morph @@ -176,16 +147,13 @@ git commit --quiet -m "add morphs" # Make a dummy kernel chunk. mkdir "$DATADIR/kernel-repo" cat < "$DATADIR/kernel-repo/linux.morph" -{ - "name": "linux", - "kind": "chunk", - "install-commands": [ - "mkdir -p \"\$DESTDIR/boot\"", - "touch \"\$DESTDIR\"/extlinux.conf", - "touch \"\$DESTDIR\"/boot/vmlinuz", - "touch \"\$DESTDIR\"/boot/System.map" - ] -} +name: linux +kind: chunk +install-commands: + - mkdir -p "\$DESTDIR/boot" + - touch "\$DESTDIR/extlinux.conf" + - touch "\$DESTDIR/boot/vmlinuz" + - touch "\$DESTDIR/boot/System.map" EOF "$SRCDIR/scripts/run-git-in" "$DATADIR/kernel-repo" init --quiet "$SRCDIR/scripts/run-git-in" "$DATADIR/kernel-repo" add . diff --git a/tests.as-root/tarball-image-is-sensible.setup b/tests.as-root/tarball-image-is-sensible.setup index c1c88993..e159070c 100755 --- a/tests.as-root/tarball-image-is-sensible.setup +++ b/tests.as-root/tarball-image-is-sensible.setup @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2011, 2012 Codethink Limited +# Copyright (C) 2011-2013 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 @@ -71,7 +71,7 @@ git add hello-tarball.morph # Change build-depends ref of hello-stratum from master to tarball-links sed -i linux-stratum.morph \ - -e '/"build-depends": \[/,/\]/ s/"ref": "master"/"ref": "tarball-links"/' + -e '/build-depends:/,/chunks/ s/ref: master/ref: tarball-links/' git add linux-stratum.morph diff --git a/tests.as-root/target-disk-too-small.script b/tests.as-root/target-disk-too-small.script index 92a73a58..ff3a374f 100755 --- a/tests.as-root/target-disk-too-small.script +++ b/tests.as-root/target-disk-too-small.script @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2011, 2012 Codethink Limited +# Copyright (C) 2011-2013 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 @@ -24,8 +24,8 @@ set -eu # Shrink linux-system to the minimum btrfs will allow. cd "$DATADIR/morphs" -sed -e 's/"system-kind": "syslinux-disk"/"system-kind": "disk"/' \ - -e 's/"disk-size": "1G"/"disk-size": "512M"/' \ +sed -e 's/system-kind: syslinux-disk/system-kind: disk/' \ + -e 's/disk-size: 1G/disk-size: 512M/' \ -i linux-system.morph git add linux-system.morph git commit -q -m "Make linux-system as small as possible" -- cgit v1.2.1 From e6dc394c0f31429b2f54c77b20223651a0ab68ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Tue, 22 Jan 2013 18:23:39 +0000 Subject: Remove unneded json module imports --- morphlib/plugins/branch_and_merge_plugin.py | 1 - morphlib/plugins/tarball-systembuilder_plugin.py | 3 +-- scripts/convert-git-cache | 5 +---- source-stats | 3 +-- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 88c017c8..04893184 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -17,7 +17,6 @@ import cliapp import copy import glob -import json import logging import os import shutil diff --git a/morphlib/plugins/tarball-systembuilder_plugin.py b/morphlib/plugins/tarball-systembuilder_plugin.py index 14807924..02622067 100644 --- a/morphlib/plugins/tarball-systembuilder_plugin.py +++ b/morphlib/plugins/tarball-systembuilder_plugin.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012,2013 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 @@ -14,7 +14,6 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import json import logging import os from os.path import relpath diff --git a/scripts/convert-git-cache b/scripts/convert-git-cache index 95ed83c8..33a8edf1 100755 --- a/scripts/convert-git-cache +++ b/scripts/convert-git-cache @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012,2013 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 @@ -15,9 +15,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# This is a program to convert the json dump of the overlaps between artifacts -# in a format more suited to shell programs, or human reading - set -eu CACHE_ROOT=$(morph --dump-config | grep cachedir | cut -d\ -f3) diff --git a/source-stats b/source-stats index c246bab9..811fdc3b 100755 --- a/source-stats +++ b/source-stats @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012,2013 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 @@ -17,7 +17,6 @@ import cliapp import csv -import json import os import shutil import sys -- cgit v1.2.1