[py3k] more print_function
Mostly in comments and defunct tools.
Related to #1167312
--- a/rql/__init__.py Tue Sep 08 18:08:07 2015 +0200
+++ b/rql/__init__.py Wed Sep 09 11:16:17 2015 +0200
@@ -124,7 +124,7 @@
The tree is modified in-place.
"""
- #print 'simplify', rqlst.as_string(encoding='UTF8')
+ #print('simplify', rqlst.as_string())
if rqlst.TYPE == 'select':
from rql import nodes
for select in rqlst.children:
--- a/rql/analyze.py Tue Sep 08 18:08:07 2015 +0200
+++ b/rql/analyze.py Wed Sep 09 11:16:17 2015 +0200
@@ -70,7 +70,7 @@
#import time
#t0=time.time()
sols = solver.solve(repo, verbose=(True or self.debug))
- #print "RUNTIME:", time.time()-t0
+ #print("RUNTIME:", time.time()-t0)
return sols
def add_var(self, name, values):
@@ -208,7 +208,7 @@
for var, val in zip(self.ivariables, s):
r[var] = self.all_values[val]
rql_sols.append(r)
- #print "RUNTIME:", time.time()-t0
+ #print("RUNTIME:", time.time()-t0)
return rql_sols
def add_var(self, name, values):
@@ -223,8 +223,8 @@
self.all_values = list(self.all_values)
# maps value->integer
self.values = dict( [ (v,i) for i,v in enumerate(self.all_values)] )
- #print self.values
- #print self.domains
+ #print(self.values)
+ #print(self.domains)
for var_name in self.ivariables:
val_domain = self.domains[var_name]
idx_domain = [ self.values[val] for val in val_domain ]
--- a/rql/compare.py Tue Sep 08 18:08:07 2015 +0200
+++ b/rql/compare.py Wed Sep 09 11:16:17 2015 +0200
@@ -18,6 +18,8 @@
"""Comparing syntax trees.
"""
+from __future__ import print_function
+
__docformat__ = "restructuredtext en"
@@ -50,7 +52,7 @@
var.name = ':'.join(name_parts)
sort(canon)
if verbose:
- print 'CANON FOR', rql_tree
+ print('CANON FOR', rql_tree)
from pprint import pprint
pprint(canon)
return canon
--- a/rql/parser_main.py Tue Sep 08 18:08:07 2015 +0200
+++ b/rql/parser_main.py Wed Sep 09 11:16:17 2015 +0200
@@ -18,6 +18,8 @@
"""Main parser command.
"""
+from __future__ import print_function
+
__docformat__ = "restructuredtext en"
if __name__ == '__main__':
@@ -28,11 +30,11 @@
# parse the RQL string
try:
tree = parser.goal(e_types)
- print '-'*80
- print tree
- print '-'*80
- print repr(tree)
- print e_types
+ print('-'*80)
+ print(tree)
+ print('-'*80)
+ print(repr(tree))
+ print(e_types)
except SyntaxError, ex:
# try to get error message from yapps
from yapps.runtime import print_error
--- a/test/unittest_parser.py Tue Sep 08 18:08:07 2015 +0200
+++ b/test/unittest_parser.py Wed Sep 09 11:16:17 2015 +0200
@@ -321,8 +321,8 @@
def test_spec(self):
"""test all RQL string found in the specification and test they are well parsed"""
for rql in SPEC_QUERIES:
-# print "Orig:", rql
-# print "Resu:", rqltree
+# print("Orig:", rql)
+# print("Resu:", rqltree)
yield self.parse, rql, True
def test_raise_badsyntax_error(self):
--- a/tools/bench_cpprql.py Tue Sep 08 18:08:07 2015 +0200
+++ b/tools/bench_cpprql.py Wed Sep 09 11:16:17 2015 +0200
@@ -15,6 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with rql. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
from rql.rqlparse import parse
import sys
@@ -39,13 +41,13 @@
}
if len(sys.argv)<2:
- print "Usage: bench_cpprql file"
- print " file: a file containing rql queries"
+ print("Usage: bench_cpprql file")
+ print(" file: a file containing rql queries")
sys.exit(1)
-f = file(sys.argv[1])
+f = open(sys.argv[1])
for l in f:
- #print l,
+ #print(l, end="")
x = parse(l, builder)
- print ".",
+ print(".", end="")
--- a/tools/bench_pyrql.py Tue Sep 08 18:08:07 2015 +0200
+++ b/tools/bench_pyrql.py Wed Sep 09 11:16:17 2015 +0200
@@ -15,10 +15,12 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with rql. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
from rql import parse
import sys
-f = file(sys.argv[1])
+f = open(sys.argv[1])
for l in f:
parse(l)
- print ".",
+ print(".", end="")
--- a/tools/rql_analyze.py Tue Sep 08 18:08:07 2015 +0200
+++ b/tools/rql_analyze.py Wed Sep 09 11:16:17 2015 +0200
@@ -15,6 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with rql. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
from ginco.server.schema_readers import load_schema
from rql import RQLHelper
from rql.analyze import AltETypeResolver, Alt2ETypeResolver, ETypeResolver, ETypeResolver2
@@ -27,22 +29,22 @@
schema = load_schema(SCHEMA_DIRECTORY, APP_NAME )
-#print schema
+#print(schema)
def cmp_sol( sol1, sol2 ):
ret = True
for l in sol1:
if l not in sol2:
ret = False
- print "Sol1", l
+ print("Sol1", l)
for l in sol2:
if l not in sol1:
ret = False
- print "Sol2", l
+ print("Sol2", l)
return ret
def analyze_rq( rq ):
- print "RQL:", rq
+ print("RQL:", rq)
helper1 = RQLHelper( schema, Resolver=ETypeResolver )
helper2 = RQLHelper( schema, Resolver=ETypeResolver2 )
node1 = helper1.parse( rq )
@@ -52,11 +54,11 @@
return helper1, helper2, node1, node2, sol1, sol2
if len(sys.argv)<2:
- print "Usage: rql_analyze.py file"
+ print("Usage: rql_analyze.py file")
sys.exit(1)
-for l in file(sys.argv[1]):
+for l in open(sys.argv[1]):
helper1, helper2, node1, node2, sol1, sol2 = analyze_rq(l)
an1 = helper1._rql_analyser
an2 = helper2._rql_analyser
--- a/tools/rql_cmp.py Tue Sep 08 18:08:07 2015 +0200
+++ b/tools/rql_cmp.py Wed Sep 09 11:16:17 2015 +0200
@@ -15,6 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with rql. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
from rql.rqlparse import parse as cparse
from rql import parse
from rql.compare2 import compare_tree, RQLCanonizer, make_canon_dict
@@ -43,17 +45,17 @@
f = file(sys.argv[1])
for l in f:
- #print l,
+ #print(l, end="")
x1 = cparse(l, builder)
x2 = parse(l)
l = l.strip()
d1 = make_canon_dict( x1 )
d2 = make_canon_dict( x2 )
t = d1==d2
- print '%s : "%s"' % (t,l)
+ print('%s : "%s"' % (t,l))
if not t:
- print "CPP",x1
+ print("CPP",x1)
pprint(d1)
- print "PYT",x2
+ print("PYT",x2)
pprint(d2)