update code to be python3-compatible

This mostly fixes print statements and some pep8 issues.

Change-Id: Ie4fb0ac8955759954d882988d698fb4aace61de1
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-10-03 17:06:04 -04:00
parent 5d83b029f4
commit 6d0b0aef62
3 changed files with 33 additions and 29 deletions

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from __future__ import print_function
import ast import ast
import argparse import argparse
import importlib import importlib
@ -152,41 +154,41 @@ def run():
exit_code = 0 exit_code = 0
if len(missing_uuids) > 0: if len(missing_uuids) > 0:
exit_code = 1 exit_code = 1
print "### Idempotent ID Errors Detected. To resolve these errors, " \ print("### Idempotent ID Errors Detected. To resolve these errors, "
"fix the uuid name (format id-<uuid>) in the guideline to " \ "fix the uuid name (format id-<uuid>) in the guideline to "
"match the id in the test suite:" "match the id in the test suite:")
for test in missing_uuids: for test in missing_uuids:
print "Idempotent ID in guideline '%s' does not appear in test " \ print("Idempotent ID in guideline '%s' does not appear in test "
"library '%s'\n" \ "library '%s'\n"
" idempotent_id:\n" \ " idempotent_id:\n"
" %s\n" \ " %s\n"
" names: " % (args.guideline_file, args.testlib, test[0]) " names: " % (args.guideline_file, args.testlib, test[0]))
for testname in test[1]: for testname in test[1]:
print " %s" % (testname) print(" %s" % (testname))
print "" print("")
if len(missing_tests) > 0: if len(missing_tests) > 0:
exit_code = 1 exit_code = 1
print "### Test Name Errors Detected. " \ print("### Test Name Errors Detected. "
"To resolve these errors, update " \ "To resolve these errors, update "
"the Interop guideline with the missing " \ "the Interop guideline with the missing "
"test names:" "test names:")
for uuid in missing_tests: for uuid in missing_tests:
print "Test found in test library '%s'\n" \ print("Test found in test library '%s'\n"
" idempotent_id:\n" \ " idempotent_id:\n"
" %s\n" \ " %s\n"
" name:\n" \ " name:\n"
" %s\n" \ " %s\n"
"Entry in guideline '%s'\n" \ "Entry in guideline '%s'\n"
" idempotent_id:\n" \ " idempotent_id:\n"
" %s\n" \ " %s\n"
" names: " % (args.testlib, " names: " % (args.testlib,
uuid, tests[uuid], uuid, tests[uuid],
args.guideline_file, args.guideline_file,
missing_tests[uuid][0]) missing_tests[uuid][0]))
for testname in missing_tests[uuid][1]: for testname in missing_tests[uuid][1]:
print " %s" % (testname) print(" %s" % (testname))
print "" print("")
sys.exit(exit_code) sys.exit(exit_code)

View File

@ -57,7 +57,7 @@ if not isinstance(data, dict):
outFileName = 'doc/source/guidelines/' + inFileName.replace("json", "rst") outFileName = 'doc/source/guidelines/' + inFileName.replace("json", "rst")
print ("Writing to: " + outFileName) print("Writing to: " + outFileName)
# intro # intro

View File

@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from __future__ import print_function
import re import re
import json import json
import argparse import argparse
@ -194,7 +196,7 @@ with open(args.score_file_name) as filehandle:
# And stdout is useful for folks who are experimenting with # And stdout is useful for folks who are experimenting with
# the effect of changing a score. # the effect of changing a score.
print "%s: %d%s" % (cap_name, total, meets_criteria) print("%s: %d%s" % (cap_name, total, meets_criteria))
# Now we can write the text output file. # Now we can write the text output file.
with open(args.text_outfile_name, 'w') as outfile: with open(args.text_outfile_name, 'w') as outfile:
@ -202,5 +204,5 @@ with open(args.text_outfile_name, 'w') as outfile:
outfile.write(line) outfile.write(line)
outfile.close() outfile.close()
print "\n\nText output has been written to %s" % args.text_outfile_name print("\n\nText output has been written to %s" % args.text_outfile_name)
print "CSV output has been written to %s" % args.csv_outfile_name print("CSV output has been written to %s" % args.csv_outfile_name)