1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
Description: Fix print statements into print() calls
This fixes Python 3 compat.
Author: Thomas Goirand <zigo@debian.org>
Forwarded: https://github.com/ativelkov/yaql/pull/15
Last-Update: 2014-09-25
--- python-yaql-0.2.3.orig/yaql/cli/run.py
+++ python-yaql-0.2.3/yaql/cli/run.py
@@ -30,7 +30,7 @@ def main():
decoder = JSONDecoder()
data = decoder.decode(json_str)
except:
- print "Unable to load data from "+options.data
+ print("Unable to load data from "+options.data)
return
else:
data = None
--- python-yaql-0.2.3.orig/yaql/cli/cli_functions.py
+++ python-yaql-0.2.3/yaql/cli/cli_functions.py
@@ -30,14 +30,14 @@ PROMPT = "yaql> "
@ContextAware()
def main(context):
- print "Yet Another Query Language - command-line query tool"
- print "Version {0}".format(version)
- print "Copyright (c) 2013 Mirantis, Inc"
- print
+ print("Yet Another Query Language - command-line query tool")
+ print("Version {0}".format(version))
+ print("Copyright (c) 2013 Mirantis, Inc")
+ print("")
if not context.get_data():
- print "No data loaded into context "
- print "Type '@load data-file.json' to load data"
- print
+ print("No data loaded into context ")
+ print("Type '@load data-file.json' to load data")
+ print("")
readline.parse_and_bind('')
@@ -52,7 +52,7 @@ def main(context):
if comm[0] == '@':
funcName, args = parse_service_command(comm)
if funcName not in SERVICE_FUNCTIONS:
- print "Unknown command " + funcName
+ print("Unknown command " + funcName)
else:
SERVICE_FUNCTIONS[funcName](args, context)
continue
@@ -61,37 +61,37 @@ def main(context):
except YaqlParsingException as ex:
if ex.position:
pointer_string = (" " * (ex.position + len(PROMPT))) + '^'
- print pointer_string
- print ex.message
+ print(pointer_string)
+ print(ex.message)
continue
try:
res = expr.evaluate(context=Context(context))
if isinstance(res, types.GeneratorType):
res = limit(res)
- print json.dumps(res, indent=4)
+ print(json.dumps(res, indent=4))
except Exception as ex:
- print "Execution exception:"
+ print("Execution exception:")
if hasattr(ex, 'message'):
- print ex.message
+ print(ex.message)
else:
- print "Unknown"
+ print("Unknown")
def load_data(data_file, context):
try:
json_str = open(os.path.expanduser(data_file)).read()
except IOError as e:
- print "Unable to read data file '{0}': {1}".format(data_file,
- e.strerror)
+ print("Unable to read data file '{0}': {1}".format(data_file,
+ e.strerror))
return
try:
decoder = JSONDecoder()
data = decoder.decode(json_str)
except Exception as e:
- print "Unable to parse data: " + e.message
+ print("Unable to parse data: " + e.message)
return
context.set_data(data)
- print "Data from file '{0}' loaded into context".format(data_file)
+ print("Data from file '{0}' loaded into context".format(data_file))
--- python-yaql-0.2.3.orig/examples/runner.py
+++ python-yaql-0.2.3/examples/runner.py
@@ -33,11 +33,11 @@ results = [expr.evaluate(data, context)
i = 1
for res in results:
- print "result #{0}".format(i)
+ print("result #{0}".format(i))
i += 1
if isinstance(res, collections.Iterable):
for r in res:
- print r
+ print(r)
else:
- print res
+ print(res)
|