From a622b7fe17a94698c1d242772d5d1b1d48761a29 Mon Sep 17 00:00:00 2001 From: eschcam Date: Mon, 19 Jun 2023 17:39:10 +0100 Subject: Migrate Python 2 files to Python 3 Issue-ID: SDC-4498 Signed-off-by: eschcam Change-Id: I6b55fcd799371dd209898607c90d5c348e242c36 --- .../action_library_client/action_library_client.py | 59 +++++++++++----------- openecomp-be/tools/build/scripts/parse-json.py | 14 ++--- 2 files changed, 38 insertions(+), 35 deletions(-) (limited to 'openecomp-be/tools/build') diff --git a/openecomp-be/tools/build/scripts/action_library_client/action_library_client.py b/openecomp-be/tools/build/scripts/action_library_client/action_library_client.py index 7f513afe86..0537128665 100644 --- a/openecomp-be/tools/build/scripts/action_library_client/action_library_client.py +++ b/openecomp-be/tools/build/scripts/action_library_client/action_library_client.py @@ -147,6 +147,7 @@ class FinalizeStatus(object): class ArgsDict(dict): """A dict which makes attributes accessible as properties.""" + def __getattr__(self, attr): return self[attr] @@ -221,33 +222,33 @@ class ArgumentParser(object): def usage(): """Print usage message.""" print("" + - "Usage: action_library_client.py [--help] [--url ] [--in ]\n" + - " [--out ] [--config ]\n" + - " [--log ] [--uuid ]\n" + - " [--curl] [--dryrun] [--verbose] [--version]\n" + - " [--list | --create | --update= | --delete |\n" + - " --checkout | --undocheckout | --checkin | --submit]\n" + - "\n" + - "Optional arguments:\n" + - " --help Show this help message and exit\n" + - " --url REST endpoint URL\n" + - " --in Path to JSON input file (else STDIN)\n" + - " --out Path to JSON output file (else STDOUT or logfile)\n" + - " --config Path to configuration file\n" + - " --log Path to logfile (else STDOUT)\n" + - " --uuid Action UUID, (=='actionInvariantUUID')\n" + - " --curl Use curl transport impl\n" + - " --dryrun Describe what will happen, execute nothing\n" + - " --verbose Verbose diagnostic output\n" + - " --version Print script version and exit\n" + - " --list List actions\n" + - " --create Create new action (requires --in)\n" + - " --update Update existing action (requires --uuid, --in)\n" + - " --delete Delete existing action (requires --uuid)\n" + - " --checkout Create minor version candidate (requires --uuid)\n" + - " --undocheckout Discard minor version candidate (requires --uuid)\n" + - " --checkin Create minor version from candidate (requires --uuid)\n" + - " --submit Create next major version (requires --uuid)") + "Usage: action_library_client.py [--help] [--url ] [--in ]\n" + + " [--out ] [--config ]\n" + + " [--log ] [--uuid ]\n" + + " [--curl] [--dryrun] [--verbose] [--version]\n" + + " [--list | --create | --update= | --delete |\n" + + " --checkout | --undocheckout | --checkin | --submit]\n" + + "\n" + + "Optional arguments:\n" + + " --help Show this help message and exit\n" + + " --url REST endpoint URL\n" + + " --in Path to JSON input file (else STDIN)\n" + + " --out Path to JSON output file (else STDOUT or logfile)\n" + + " --config Path to configuration file\n" + + " --log Path to logfile (else STDOUT)\n" + + " --uuid Action UUID, (=='actionInvariantUUID')\n" + + " --curl Use curl transport impl\n" + + " --dryrun Describe what will happen, execute nothing\n" + + " --verbose Verbose diagnostic output\n" + + " --version Print script version and exit\n" + + " --list List actions\n" + + " --create Create new action (requires --in)\n" + + " --update Update existing action (requires --uuid, --in)\n" + + " --delete Delete existing action (requires --uuid)\n" + + " --checkout Create minor version candidate (requires --uuid)\n" + + " --undocheckout Discard minor version candidate (requires --uuid)\n" + + " --checkin Create minor version from candidate (requires --uuid)\n" + + " --submit Create next major version (requires --uuid)") ############################################################################### @@ -533,7 +534,7 @@ class CURLRESTClient(IRESTClient): """Debug curl command, for diags and dryrun.""" buf = "" for token in cmd: - if token is "curl" or token.startswith("-"): + if token == "curl" or token.startswith("-"): buf = "{0}{1} ".format(buf, token) else: buf = "{0}\"{1}\" ".format(buf, token) @@ -556,7 +557,7 @@ class CURLRESTClient(IRESTClient): try: separator = output.index("\r\n\r\n{") self.logger.debug("HTTP preamble:\n{0}".format(output[:separator])) - json_body = json.loads(output[(separator+4):]) + json_body = json.loads(output[(separator + 4):]) self.log_json_response(method, json_body) return json_body except ValueError: diff --git a/openecomp-be/tools/build/scripts/parse-json.py b/openecomp-be/tools/build/scripts/parse-json.py index 46537ceac5..83c70aac01 100644 --- a/openecomp-be/tools/build/scripts/parse-json.py +++ b/openecomp-be/tools/build/scripts/parse-json.py @@ -41,17 +41,19 @@ from collections import OrderedDict def readJsonFile(file, type): - with open(file, 'r') as f: - data = json.load(f, object_pairs_hook=OrderedDict) - return data[type] + with open(file, 'r') as f: + data = json.load(f, object_pairs_hook=OrderedDict) + return data[type] + def printJsonTypeEntries(jsonData): - for i in jsonData.keys(): - print jsonData[i] + ';' + for i in jsonData.keys(): + print(jsonData[i] + ';') def usage(): - print 'parseJsonFile.py [-f & -t & -t