From 95505797df503a086a311cab9aecbd2318522407 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 26 Nov 2019 14:29:03 +0000 Subject: Update to python3 --- yarns.webapp/900-implementations.yarn | 40 +++++++++++++++++------------------ yarns.webapp/yarn.sh | 3 ++- yarns.webapp/yarnlib.py | 4 ++-- 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'yarns.webapp') diff --git a/yarns.webapp/900-implementations.yarn b/yarns.webapp/900-implementations.yarn index 06411a7..245cd73 100644 --- a/yarns.webapp/900-implementations.yarn +++ b/yarns.webapp/900-implementations.yarn @@ -86,7 +86,7 @@ most of the configuration. IMPLEMENTS GIVEN (\S+) in (\S+) adds lorries (\S+) using prefix (\S+) cd "$SRCDIR"/yarns.webapp - python -c ' + python3 -c ' import os import yarnlib @@ -112,7 +112,7 @@ most of the configuration. IMPLEMENTS GIVEN (\S+) in (\S+) adds trove (\S+) cd "$SRCDIR"/yarns.webapp - python -c ' + python3 -c ' import os import yarnlib @@ -138,7 +138,7 @@ file. IMPLEMENTS GIVEN (\S+) in (\S+) has (\S+) set to (.+) for everything cd "$SRCDIR"/yarns.webapp - python -c ' + python3 -c ' import os import json import yarnlib @@ -159,7 +159,7 @@ Set a specific field for a `troves` section. IMPLEMENTS GIVEN (\S+) in (\S+) sets (\S+) to (.+) for trove (\S+) cd "$SRCDIR"/yarns.webapp - python -c ' + python3 -c ' import os import json import yarnlib @@ -182,7 +182,7 @@ Remove a specified field for a `troves` section IMPLEMENTS GIVEN (\S+) in (\S+) removes field (\S+) from trove (\S+) cd "$SRCDIR"/yarns.webapp - python -c ' + python3 -c ' import os import yarnlib @@ -204,7 +204,7 @@ file. Note that the Trove must already be in the configuration file. IMPLEMENTS GIVEN (\S+) in (\S+) has prefixmap (\S+):(\S+) for (\S+) cd "$SRCDIR"/yarns.webapp - python -c ' + python3 -c ' import os import yarnlib @@ -242,7 +242,7 @@ Control the ls listing of a remote Trove. echo "{}" > "$filename" fi cat "$filename" - python -c ' + python3 -c ' import json, os, sys MATCH_2 = os.environ["MATCH_2"] filename = sys.argv[1] @@ -262,7 +262,7 @@ Remove a repository from the fake remote Trove. echo "{}" > "$filename" fi cat "$filename" - python -c ' + python3 -c ' import json, os, sys MATCH_2 = os.environ["MATCH_2"] filename = sys.argv[1] @@ -334,7 +334,7 @@ value is expresssed as a JSON value in the step. IMPLEMENTS THEN response has (\S+) set to (.+) cat "$DATADIR/response.body" - python -c ' + python3 -c ' import json, os, sys data = json.load(sys.stdin) key = os.environ["MATCH_1"] @@ -353,22 +353,22 @@ we may need to look at a list of dicts, as below. IMPLEMENTS THEN response has (\S+) item (\d+) field (\S+) set to (\S+) cat "$DATADIR/response.body" - python -c ' + python3 -c ' import json, os, sys data = json.load(sys.stdin) - print "data:", repr(data) + print("data:", repr(data)) items = os.environ["MATCH_1"] - print "items:", repr(items) + print("items:", repr(items)) item = int(os.environ["MATCH_2"]) - print "item:", repr(item) + print("item:", repr(item)) field = os.environ["MATCH_3"] - print "field:", repr(field) - print "match3:", repr(os.environ["MATCH_4"]) + print("field:", repr(field)) + print("match3:", repr(os.environ["MATCH_4"])) expected = json.loads(os.environ["MATCH_4"]) - print "expected:", repr(expected) - print "data[items]:", repr(data[items]) - print "data[items][item]:", repr(data[items][item]) - print "data[items][item][field]:", repr(data[items][item][field]) + print("expected:", repr(expected)) + print("data[items]:", repr(data[items])) + print("data[items][item]:", repr(data[items][item])) + print("data[items][item][field]:", repr(data[items][item][field])) value = data[items][item][field] if value != expected: sys.stderr.write( @@ -384,7 +384,7 @@ value, but we do care that it is there. IMPLEMENTS THEN response has (\S+) set cat "$DATADIR/response.body" - python -c ' + python3 -c ' import json, os, sys data = json.load(sys.stdin) key = os.environ["MATCH_1"] diff --git a/yarns.webapp/yarn.sh b/yarns.webapp/yarn.sh index 2a9081d..260fd74 100644 --- a/yarns.webapp/yarn.sh +++ b/yarns.webapp/yarn.sh @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2019 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 @@ -40,6 +40,7 @@ add_to_config_file() then printf '[config]\n' > "$1" fi + sed -i "/^$2/d" "$1" printf '%s = %s\n' "$2" "$3" >> "$1" } diff --git a/yarns.webapp/yarnlib.py b/yarns.webapp/yarnlib.py index 89f87d9..4582649 100644 --- a/yarns.webapp/yarnlib.py +++ b/yarns.webapp/yarnlib.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Codethink Limited +# Copyright (C) 2015-2019 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 @@ def matches(): matches = {} prefix = "MATCH_" - for key, value in os.environ.iteritems(): + for key, value in os.environ.items(): if key.startswith(prefix): stripped_key = key[len(prefix):] if stripped_key.isdigit() and stripped_key != "0": -- cgit v1.2.1