[magics] 02/63: WIP: More python3 changes
Alastair McKinstry
mckinstry at moszumanska.debian.org
Fri Mar 24 10:41:41 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository magics.
commit a80675e58ce6c1168e6bd5ff10cca1914894e736
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Sun May 17 10:59:21 2015 +0100
WIP: More python3 changes
---
debian/patches/python3.patch | 824 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 788 insertions(+), 36 deletions(-)
diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
index f9e6d5e..03c430a 100644
--- a/debian/patches/python3.patch
+++ b/debian/patches/python3.patch
@@ -1,51 +1,803 @@
-Author: Alastair McKinstry <mckinstry at debian.org>
-Description: Support for python3
-Forwarded: no
-Last-Updaged: 2015-05-01
-
+Index: magics++-2.24.4/tools/axis2doc.py
+===================================================================
+--- magics++-2.24.4.orig/tools/axis2doc.py
++++ magics++-2.24.4/tools/axis2doc.py
+@@ -1,4 +1,6 @@
+ #!/usr/bin/python
++
++from __future__ import print_function
+ from xml.sax.handler import ContentHandler
+ from xml.sax import make_parser
+ from types import *
+@@ -40,7 +42,7 @@ class ObjectHandler(ContentHandler):
+
+ def anyset(p, attrs):
+ p["set"] = "psetc"
+- if attrs.has_key("values") :
++ if "values" in attrs:
+ val = attrs["values"]
+ values = val.split("/")
+ p["values"] = values
+@@ -88,21 +90,18 @@ class ObjectHandler(ContentHandler):
+
+
+ def get(self, attrs, name, default):
+- if attrs.has_key(name):
+- return attrs.get(name)
+- else :
+- return default
++ return attrs.get(name, default)
+
+ def newparam(self, attrs):
+ p = {}
+ self.parameters[attrs.get("name")] = p
+ p["name"] = attrs.get("name")
+ p["type"] = attrs.get("to")
+- if attrs.has_key("metview") :
++ if "metview" in attrs:
+ p["metview"]= attrs["metview"]
+ p["values"] = []
+ t = p["type"]
+- if self.types.has_key(t) :
++ if t in self.types:
+ self.types[t](p, attrs)
+ else :
+ p["set"]="psetc"
+@@ -117,7 +116,7 @@ class ObjectHandler(ContentHandler):
+ o["name"] = attrs.get("name")
+ o["documentation"] = ""
+ o["parameters"] = []
+- if attrs.has_key("inherits") :
++ if "inherits" in attrs:
+ o["inherits"]=attrs.get("inherits")
+
+ return o
+@@ -139,12 +138,12 @@ class ObjectHandler(ContentHandler):
+ if ( name == "option") :
+ val = attrs.get("fortran")
+ self.param["values"].append(val)
+- if ( self.param.has_key(val) == False ):
++ if val not in self.param:
+ self.param[val] = []
+ self.param[val].append(attrs.get("name"))
+ if ( name == "set" ) :
+ val = attrs.get("value")
+- if ( self.param.has_key(val) == False ):
++ if val not in self.param:
+ self.param[val] = []
+ self.param[val].append(attrs.get("name"))
+
+@@ -167,7 +166,7 @@ class ObjectHandler(ContentHandler):
+ self.actiondoc= ""
+
+ def printDef(self):
+- print json.dumps(self.magics, indent=2)
++ print (json.dumps(self.magics, indent=2))
+
+
+ def parse(self, file):
+@@ -180,21 +179,21 @@ class ObjectHandler(ContentHandler):
+
+ def prepare(self, defparam):
+ param = defparam.copy()
+- print "prepare-->"
+- print param
+- print "<---prepare"
+- if param.has_key("values") == False:
++ print ("prepare-->")
++ print (param)
++ print ("<---prepare")
++ if "values" not in param:
+ return param
+ if len(param["values"]) == 0:
+ return param
+ for val in param["values"]:
+- print val + " For " + param["name"]
++ print (val + " For " + param["name"])
+ newp = []
+- if param.has_key(val):
++ if val in param):
+ for v in param[val]:
+- print "prepare-->" + v
++ print ("prepare-->" + v)
+ # Can be a parameter or another object!
+- if self.parameters.has_key(v) :
++ if v in self.parameters:
+ self.append(newp, v)
+ else:
+ self.append(newp, self.getList(v))
+@@ -210,7 +209,7 @@ class ObjectHandler(ContentHandler):
+ def getList(self, object):
+ definition = self.magics[object]
+ list = []
+- if definition.has_key("inherits"):
++ if "inherits" in definition:
+ self.append(list, self.getList(definition["inherits"]))
+ for p in definition["parameters"]:
+ list.append(p["name"])
+@@ -220,8 +219,8 @@ class ObjectHandler(ContentHandler):
+
+ def buildParam(self, param):
+ parameters = []
+- if param.has_key("inherits"):
+- print param["name"] + " inherits from " + param["inherits"]
++ if "inherits" in param:
++ print (param["name"] + " inherits from " + param["inherits"])
+ parent = self.buildParam(self.magics[param["inherits"]])
+ self.append(parameters, parent)
+ parameters.append(self.prepare(param))
+@@ -232,8 +231,8 @@ class ObjectHandler(ContentHandler):
+ def build(self, params):
+ parameters = []
+ for p in params:
+- print "find class " + p
+- if ( self.magics.has_key(p) ) :
++ print ("find class " + p)
++ if p in self.magics:
+ defp = self.magics[p]
+ # internal object
+ for p in defp["parameters"]:
+Index: magics++-2.24.4/tools/beau.py
+===================================================================
+--- magics++-2.24.4.orig/tools/beau.py
++++ magics++-2.24.4/tools/beau.py
+@@ -1,10 +1,10 @@
+-
++from __future__ import print_function
+ import xml.dom.minidom
+
+ xml = xml.dom.minidom.parse("../src/xml/TextVisitor.xml") # or xml.dom.minidom.parseString(xml_string)
+ pretty_xml_as_string = xml.toprettyxml()
+
+
+-print pretty_xml_as_string
++print (pretty_xml_as_string)
+
+
+Index: magics++-2.24.4/tools/xml2doc.py
+===================================================================
+--- magics++-2.24.4.orig/tools/xml2doc.py
++++ magics++-2.24.4/tools/xml2doc.py
+@@ -1,4 +1,4 @@
+-
++from __future__ import print_function
+ from xml.sax.handler import ContentHandler
+ from xml.sax import make_parser
+ import sys
+@@ -122,7 +122,7 @@ class ObjectHandler(ContentHandler):
+ if self.inherits != '':
+ try:
+ file = open("xml/%s.xml" % attrs.get("inherits"), "r")
+- print " inherits ->%s" % self.inherits
++ print (" inherits ->%s" % self.inherits)
+ object = ObjectHandler()
+ parser = make_parser()
+ object.params = []
+Index: magics++-2.24.4/tools/xml2html.py
+===================================================================
+--- magics++-2.24.4.orig/tools/xml2html.py
++++ magics++-2.24.4/tools/xml2html.py
+@@ -1,4 +1,5 @@
+ #!/usr/bin/python
++from __future__ import print_function
+ from xml.sax.handler import ContentHandler
+ from xml.sax import make_parser
+ from types import *
+@@ -26,7 +27,7 @@ class ObjectHandler(ContentHandler):
+ p["type"] = "toggle"
+
+ def anyset(p, attrs):
+- if attrs.has_key("values") :
++ if "values" in attrs:
+ val = attrs["values"]
+ values = val.split("/")
+ p["values"] = values
+@@ -42,7 +43,7 @@ class ObjectHandler(ContentHandler):
+
+
+ def get(self, attrs, name, default):
+- if attrs.has_key(name):
++ if name in attrs:
+ return attrs.get(name)
+ else :
+ return default
+@@ -53,7 +54,7 @@ class ObjectHandler(ContentHandler):
+ p["type"] = attrs.get("to")
+ p["values"] = []
+ t = p["type"]
+- if self.types.has_key(t) :
++ if t in self.types:
+ self.types[t](p, attrs)
+ else :
+ p["type"]="toggle"
+@@ -68,9 +69,9 @@ class ObjectHandler(ContentHandler):
+ o["name"] = attrs.get("name")
+ o["documentation"] = ""
+ o["parameters"] = []
+- if attrs.has_key("inherits") :
++ if "inherits" in attrs:
+ o["inherits"]=attrs.get("inherits")
+- print o["name"] + " inhrits from " + o["inherits"]
++ print (o["name"] + " inhrits from " + o["inherits"])
+ return o
+
+ def startElement(self, name, attrs):
+@@ -90,12 +91,12 @@ class ObjectHandler(ContentHandler):
+ if ( name == "option") :
+ val = attrs.get("fortran")
+ self.param["values"].append(val)
+- if ( self.param.has_key(val) == False ):
++ if "val" not in self.param:
+ self.param[val] = []
+ self.param[val].append(attrs.get("name"))
+ if ( name == "set" ) :
+ val = attrs.get("value")
+- if ( self.param.has_key(val) == False ):
++ if "val" not in self.param:
+ self.param[val] = []
+ self.param[val].append(attrs.get("name"))
+
+@@ -118,7 +119,7 @@ class ObjectHandler(ContentHandler):
+ self.actiondoc= ""
+
+ def printDef(self):
+- print json.dumps(self.magics, indent=2)
++ print (json.dumps(self.magics, indent=2))
+
+
+ def parse(self, file):
+@@ -133,25 +134,25 @@ class ObjectHandler(ContentHandler):
+ parameters = []
+
+ for a in actions:
+- if ( type(a) != dict and self.magics.has_key(a) ) :
++ if ( type(a) != dict and a in self.magics) :
+ # external object
+ action = self.magics[a]
+- if action.has_key("inherits") :
++ if "inherits" in action:
+ parent = action["inherits"]
+ definition = self.magics[parent]
+- print a + " xxxxinherits from " + parent
++ print ( a + " xxxxinherits from " + parent)
+
+- print "??????????????????"
++ print ("??????????????????")
+ for p in definition["parameters"]:
+- print p["name"]
++ print (p["name"] )
+ parameters.append(p)
+- print "---------------"
++ print ("---------------")
+
+ for param in action["parameters"]:
+ #print "add" + param["name"]
+ parameters.append(param)
+ for val in param["values"]:
+- if param.has_key(val) :
++ if val in param:
+ param[val] = self.build(param[val], action)
+ else :
+ param[val] = []
+Index: magics++-2.24.4/tools/xml2odt.py
+===================================================================
+--- magics++-2.24.4.orig/tools/xml2odt.py
++++ magics++-2.24.4/tools/xml2odt.py
+@@ -1,4 +1,5 @@
+ #!/usr/bin/python
++from __future__ import print_function
+ from xml.sax.handler import ContentHandler
+ from xml.sax import make_parser
+ from types import *
+@@ -7,8 +8,8 @@ import sys
+
+
+ if(len(sys.argv) != 3) :
+- print "\n\tYou need to give 2 input parameters:"
+- print "\n\t %s source.xml target.odt\n" % sys.argv[0]
++ print ("\n\tYou need to give 2 input parameters:")
++ print ("\n\t %s source.xml target.odt\n" % sys.argv[0])
+ sys.exit()
+
+
+Index: magics++-2.24.4/tools/xml2split.py
+===================================================================
+--- magics++-2.24.4.orig/tools/xml2split.py
++++ magics++-2.24.4/tools/xml2split.py
+@@ -1,5 +1,5 @@
+
+-
++from __future__ import print_function
+ from xml.sax.handler import ContentHandler
+ from xml.sax import make_parser
+ import sys
+@@ -32,7 +32,7 @@ class ObjectHandler(ContentHandler):
+ self.file.write(data);
+
+ def startElement(self, name, attrs):
+- print "found %s " % name
++ print ("found %s " % name)
+ if (name == "magics") :
+ return
+ if (name == "static") :
+@@ -44,13 +44,13 @@ class ObjectHandler(ContentHandler):
+ self.file=open(filename, "w")
+ self.open_file = 1;
+ self.file.write("<magics>\n")
+- print "open %s " % filename
++ print ("open %s " % filename)
+ self.nice(name, attrs)
+ self.tab1 = self.tab1+1
+ self.tab2 = self.tab2+1
+
+ def endElement(self,name):
+- print "close %s\n " % name
++ print ("close %s\n " % name)
+ if ( self.open_file == 0):
+ return
+
+Index: magics++-2.24.4/tools/xml2mv.py
+===================================================================
+--- magics++-2.24.4.orig/tools/xml2mv.py
++++ magics++-2.24.4/tools/xml2mv.py
+@@ -1,4 +1,5 @@
+ #!/usr/bin/python
++from __future__ import print_function
+ from xml.sax.handler import ContentHandler
+ from xml.sax import make_parser
+ from types import *
+@@ -7,8 +8,8 @@ import sys
+
+
+ if(len(sys.argv) != 6) :
+- print "\n\tYou need to give 4 input parameters:"
+- print "\n\t %s source.xml targetDef CLASS_NAME rulesDef\n" % sys.argv[0]
++ print ("\n\tYou need to give 4 input parameters:")
++ print ("\n\t %s source.xml targetDef CLASS_NAME rulesDef\n" % sys.argv[0])
+ sys.exit()
+
+
+@@ -311,7 +312,7 @@ class ObjectHandler(ContentHandler):
+
+
+ def addOptionalParam(self, paramname, requirements):
+- if paramname in self.optionalparams.keys():
++ if paramname in self.optionalparams:
+ if not(requirements[0] in self.optionalparams[paramname]):
+ self.optionalparams[paramname] = self.optionalparams[paramname] + requirements
+ else:
+@@ -319,7 +320,7 @@ class ObjectHandler(ContentHandler):
+
+
+ def addRelatedOptionalRequirements(self):
+- optparams = self.optionalparams.keys()
++ optparams = list(self.optionalparams.keys())
+ for optparam in optparams:
+ conditions = self.optionalparams[optparam]
+ for condition in conditions:
+@@ -328,7 +329,7 @@ class ObjectHandler(ContentHandler):
+
+
+ def addRelatedOptionalRequirements2(self):
+- optparams = self.optionalparams.keys()
++ optparams = list(self.optionalparams.keys())
+ for optparam in optparams:
+ conditions = self.optionalparams[optparam]
+ for condition in conditions:
+@@ -341,9 +342,9 @@ class ObjectHandler(ContentHandler):
+
+ # see top of file for description of optionalparams and optionalparams2
+ def reorganiseOptionalParameters(self):
+- for optparam in self.optionalparams.keys():
++ for optparam in self.optionalparams:
+ condition = self.optionalparams[optparam]
+- if condition in self.optionalparams2.keys():
++ if condition in self.optionalparams2:
+ self.optionalparams2[condition].add(optparam)
+ else:
+ self.optionalparams2[condition] = set([optparam])
+@@ -355,7 +356,7 @@ class ObjectHandler(ContentHandler):
+ def ensureOptionalParameters2DependenciesAreInRightOrder(self):
+ self.optionalparams3 = () # empty tuple, will contain an ordered version of optionalparams2
+
+- for conditions2 in self.optionalparams2.keys():
++ for conditions2 in self.optionalparams2:
+ # does this rule unset something that is needed in the optionalparams3 rules?
+ unsetparams2 = self.optionalparams2[conditions2]
+ newtuple3 = (conditions2, unsetparams2)
+@@ -374,7 +375,7 @@ class ObjectHandler(ContentHandler):
+
+ # we now know that the clause should go into position 'position' in the new tuple
+ if self.debug:
+- print "put into position " + str(position)
++ print ("put into position " + str(position))
+ if position == 0:
+ firstpart = ()
+ secondpart = (newtuple3,)
+@@ -395,7 +396,7 @@ class ObjectHandler(ContentHandler):
+
+
+ def newClass(self, c):
+- if not (c in self.classes.keys()):
++ if not (c in self.classes):
+ self.classes[c] = {"inherits_reqs_from": set(), # 'inherits_params_from' is an empty set
+ "inherits_params_from": set()}
+ #print "newClass " + c
+@@ -437,7 +438,7 @@ class ObjectHandler(ContentHandler):
+ params = self.classes[c].get("params", ())
+ for p in params:
+ x = reqs
+- if x <> ():
++ if x != ():
+ self.addOptionalParam(p, x)
+ #self.addOptionalParam(p, (x,))
+
+@@ -455,11 +456,11 @@ class ObjectHandler(ContentHandler):
+ #print spaces + "enter rec, class = " + classname
+ for parent in i:
+ #print parent
+- if parent <> None:
++ if parent != None:
+ reqs = self.addRecursiveInheritedClassRequirements(parent, reclevel+1)
+ #print spaces + "reqs: "
+ #print reqs
+- if reqs <> None:
++ if reqs != None:
+ for req in reqs:
+ #print "ADDING REQ FROM RECURSIVE"
+ self.addRequirementToClass(req[0], req[1], classname)
+@@ -481,11 +482,11 @@ class ObjectHandler(ContentHandler):
+ #print spaces + "enter rec, class = " + classname
+ for parent in i:
+ #print parent
+- if parent <> None:
++ if parent != None:
+ params = self.addRecursiveInheritedClassParams(parent, reclevel+1)
+ #print spaces + "reqs: "
+ #print reqs
+- if params <> None:
++ if params != None:
+ for params in params:
+ #print "ADDING REQ FROM RECURSIVE"
+ self.addParamsFromOneClassToAnother(parent, classname)
+@@ -532,7 +533,7 @@ class ObjectHandler(ContentHandler):
+ try:
+ file = open(fname, "r")
+ if (self.debug):
+- print "Opened (start class)" + fname
++ print ("Opened (start class)" + fname)
+ self.filehistory.append(fname)
+ object = ObjectHandler()
+ object.myoptions = []
+@@ -568,17 +569,17 @@ class ObjectHandler(ContentHandler):
+ return
+ if (attrs.get("inherit_parent_reqs") != 'no'):
+ docclass = attrs.get("doc_class", None)
+- if docclass <> None:
++ if docclass != None:
+ paramclass = docclass
+ else:
+ paramclass = self.classname
+ self.addParameterToClass(self.param, paramclass)
+- type = attrs.get("to")
++ typ = attrs.get("to")
+ metview_type = attrs.get("metview_interface")
+- if metview_type <> None:
+- type = metview_type
+- if (self.types.has_key(type)):
+- f = self.types[type]
++ if metview_type != None:
++ typ = metview_type
++ if typ in self.types:
++ f = self.types[typ]
+ self.newparam(self.param, f(self, attrs), self.default(attrs))
+ else:
+ self.last = self.last + self.options(attrs)
+@@ -614,7 +615,7 @@ class ObjectHandler(ContentHandler):
+ file = open(fname, "r")
+ self.filehistory.append(fname)
+ if (self.debug):
+- print "Opened (start option) " + fname
++ print ("Opened (start option) " + fname)
+ object = ObjectHandler()
+ object.myoptions = []
+ object.myrules = {}
+@@ -667,8 +668,8 @@ class ObjectHandler(ContentHandler):
+ self.last = self.last + "\t} = %s\n" % self.defparam
+ self.newparam(self.param, self.last, self.defparam)
+ if (self.debug) :
+- print " endparam: " + self.param
+- print " endparam SL: \n" + self.last
++ print (" endparam: " + self.param)
++ print (" endparam SL: \n" + self.last)
+ self.last = ""
+ for option in self.myoptions:
+ for p in option:
+@@ -768,7 +769,7 @@ class ObjectHandler(ContentHandler):
+ # two different ways to generate the rules
+ if False:
+ rules = open(sys.argv[5], "w")
+- for optparam in self.optionalparams.keys():
++ for optparam in self.optionalparams:
+ rules.write("\n%if")
+ first = True
+ prevparam = ""
+@@ -845,4 +846,4 @@ saxparser.setContentHandler(object)
+
+ datasource = open(sys.argv[1] +"/" + sys.argv[2], "r")
+ saxparser.parse(datasource)
+-print "DONE"
++print ("DONE")
+Index: magics++-2.24.4/python/Magics/macro.py
+===================================================================
+--- magics++-2.24.4.orig/python/Magics/macro.py
++++ magics++-2.24.4/python/Magics/macro.py
+@@ -1,3 +1,4 @@
++from __future__ import print_function
+ import os
+ import Magics
+ import numpy
+@@ -60,7 +61,7 @@ class Action(object):
+ return x
+
+ def inspect(self):
+- print self
++ print (self)
+
+ def quote(self, v):
+ return "\"" + v + "\""
+@@ -119,12 +120,12 @@ class Action(object):
+ dim = len(self.args[key].shape)
+ if isinstance(self.args[key][0], int):
+ if (dim == 2) :
+- print "pset2i"
++ print ("pset2i")
+ else :
+- print "pset1i"
++ print I"pset1i")
+ elif ( type == 'float64' or type == 'float32') :
+ if (dim == 2) :
+- print "pset2r"
++ print ("pset2r")
+ else :
+ vval = ""
+ vsep = ""
+@@ -137,10 +138,10 @@ class Action(object):
+ vval += ""
+ val+= '%s%s = [%s]'%(sep, key, vval)
+ else :
+- print "type???->", key
++ print ("type???->", key)
+ sep=",\n\t"
+
+- print >>file, val + ")\n"
++ print (val + ")\n", file=file)
+
+ def tomv4(self, file):
+ sep="\t"
+@@ -166,20 +167,20 @@ class Action(object):
+ vval += "]"
+ val+= '%s%s = %s'%(sep, key.upper(), vval)
+ elif isinstance(self.args[key][0], int):
+- print "pset1i"
++ print ("pset1i")
+ elif isinstance(self.args[key][0], float):
+- print "pset1r"
++ print ("pset1r")
+ elif isinstance(self.args[key], numpy.ndarray) :
+ type = self.args[key].dtype
+ dim = len(self.args[key].shape)
+ if isinstance(self.args[key][0], int):
+ if (dim == 2) :
+- print "pset2i"
++ print ("pset2i")
+ else :
+- print "pset1i"
++ print ("pset1i")
+ elif ( type == 'float64' or type == 'float32') :
+ if (dim == 2) :
+- print "pset2r"
++ print ("pset2r" )
+ else :
+ vval = "["
+ vsep = ""
+@@ -190,10 +191,10 @@ class Action(object):
+ val+= '%s%s = %s'%(sep, key.upper(), vval)
+
+ else :
+- print "type???->", key
++ print ("type???->", key)
+ sep=",\n\t"
+
+- print >> file, val + "\n"
++ print (val + "\n", file=file)
+
+
+
+@@ -201,18 +202,18 @@ class Action(object):
+
+ def tofortran(self, f):
+ if self.action == Magics.new_page :
+- print >> f, '\tcall pnew("page")'
++ print ('\tcall pnew("page")', file=f)
+ return
+ for key in self.args.keys():
+ if isinstance(self.args[key], str):
+ if key == 'odb_data':
+ Magics.setc('odb_filename', self.args[key])
+ else:
+- print >> f, '\tcall psetc("%s", "%s")'%(key, self.args[key])
++ print('\tcall psetc("%s", "%s")'%(key, self.args[key]), file=f)
+ elif isinstance(self.args[key], int):
+- print >>f, '\tcall pseti("%s", %d)'%(key, self.args[key])
++ print ('\tcall pseti("%s", %d)'%(key, self.args[key]), file=f)
+ elif isinstance(self.args[key], float):
+- print >> f, '\tcall psetr("%s", %0.2f)'%(key, self.args[key])
++ print ('\tcall psetr("%s", %0.2f)'%(key, self.args[key]), file=f)
+ elif isinstance(self.args[key], list) :
+ if isinstance (self.args[key][0], str):
+ nb = 0
+@@ -229,9 +230,9 @@ class Action(object):
+ sep = ",&\n\t\t"
+ newline = newline + 70
+ val += "/)"
+- print >>f, '\tcall pset1c("%s", %s, %d)'%(key, val, len(self.args[key]))
++ print ('\tcall pset1c("%s", %s, %d)'%(key, val, len(self.args[key])), file=f)
+ elif isinstance(self.args[key][0], int):
+- print "pset1i"
++ print ("pset1i")
+ elif isinstance(self.args[key][0], float):
+ val = "(/"
+ sep = ""
+@@ -239,18 +240,18 @@ class Action(object):
+ val += sep + ("%0.2f" % v)
+ sep = ", "
+ val += "/)"
+- print >>f, '\tcall pset1r("%s", %s, %d)'%(key, val, len(self.args[key]))
++ print ('\tcall pset1r("%s", %s, %d)'%(key, val, len(self.args[key])), file=f)
+ elif isinstance(self.args[key], numpy.ndarray) :
+ type = self.args[key].dtype
+ dim = len(self.args[key].shape)
+ if isinstance(self.args[key][0], int):
+ if (dim == 2) :
+- print "pset2i"
++ print ("pset2i")
+ else :
+- print "pset1i"
++ print ("pset1i")
+ elif ( type == 'float64' or type == 'float32') :
+ if (dim == 2) :
+- print "pset2r"
++ print ("pset2r")
+ else :
+ val = "(/"
+ sep = ""
+@@ -258,20 +259,20 @@ class Action(object):
+ val += sep + ("%0.2f" % v)
+ sep = ", "
+ val += "/)"
+- print >>f, '\tcall pset1r("%s", %s, %d)'%(key, val, len(self.args[key]))
++ print ('\tcall pset1r("%s", %s, %d)'%(key, val, len(self.args[key])), file=f)
+ elif isinstance(self.args[key][0], int):
+- print "pset1r"
++ print ("pset1r" )
+ else :
+- print "type???->", key
++ print ("type???->", key)
+
+ if self.action != None and actions[self.verb] != "" and actions[self.verb] != "pinput":
+- print >>f, "\tcall %s\n"%actions[self.verb]
++ print ("\tcall %s\n"%actions[self.verb] , file=f)
+ for key in self.args.keys():
+- print >>f, "\tcall preset('%s')"%key
+- print >>f, ""
++ print ("\tcall preset('%s')"%key , file=f)
++ print ("", file=f)
+
+ else:
+- print >>f, ""
++ print ("", file=f)
+
+
+ def clean_object(self, obj):
+@@ -290,8 +291,8 @@ class Action(object):
+ for i,v in obj.iteritems():
+ obj[i] = self.clean_object(v)
+ else:
+- print "Invalid object in data, converting to string: "
+- print type(obj)
++ print ("Invalid object in data, converting to string: " )
++ print ( type(obj))
+ obj = str(obj)
+ return obj
+
+@@ -331,7 +332,7 @@ class Action(object):
+ else :
+ Magics.set1r(key, self.args[key].copy())
+ else :
+- print "type???->", key
++ print ("type???->", key)
+
+ else:
+ self.args[key].execute(key)
+@@ -439,26 +440,26 @@ def plot(*args):
+
+
+ def tofortran(file, *args):
+- f = open(file+".f90",'w')
+- print >>f, "\tprogram magics\n"
+- print >>f, "\tcall popen\n"
+- for n in args:
++ with open(file+".f90",'w') as f:
++ print ("\tprogram magics\n", file=f)
++ print ("\tcall popen\n", file=f)
++ for n in args:
+ n.tofortran(f)
+- print >>f, "\tcall pclose\n"
+- print >>f, "\tend"
++ print ("\tcall pclose\n", file=f)
++ print ("\tend", file=f)
+
+
+ def tohtml(file, *args):
+- f = open(file+".html",'w')
+- print >>f, "<html>"
+- for n in args:
+- n.tohtml(f)
+- print >>f, "</html>"
++ with open(file+".html",'w') as f:
++ print ("<html>", file=f)
++ for n in args:
++ n.tohtml(f)
++ print ("</html>", file=f)
+
+ def tomv4(file, *args):
+- f = open(file+".mv4",'w')
+- for n in args:
+- n.tomv4(f)
++ with open(file+".mv4",'w') as f:
++ for n in args:
++ n.tomv4(f)
+
+ class odb_filter(object):
+ def __init__(self, _m = None,**kw):
+@@ -472,17 +473,17 @@ class odb_filter(object):
+ odb = "%s.odb" % file
+ context.tmp.append(odb)
+ cmd = "odbsql -q \"" + self.args["query"] + "\" -i " + self.args["path"] + " -f newodb -o " + odb
+- print cmd
++ print (cmd)
+ if (os.system(cmd)) :
+- print "Error in filtering ODB data... Aborting"
++ print ("Error in filtering ODB data... Aborting")
+ os.abort();
+ Magics.setc('odb_filename', odb)
+ def inspect(self):
+ cmd = "odbsql -q \"" + self.args["query"] + "\" -i " + self.args["path"] + " -o data.ascii"
+ if (os.system(cmd)) :
+- print "Error in filtering ODB data... Aborting"
++ print ("Error in filtering ODB data... Aborting")
+ os.abort();
+ cmd = os.environ['ODB_REPORTER'] + " %s" % "data.ascii"
+ if (os.system(cmd)) :
+- print "Error in viewing ODB data... Aborting"
++ print ("Error in viewing ODB data... Aborting")
+ os.abort();
Index: magics++-2.24.4/python/Magics/metgram.py
===================================================================
--- magics++-2.24.4.orig/python/Magics/metgram.py
+++ magics++-2.24.4/python/Magics/metgram.py
-@@ -1,3 +1,5 @@
+@@ -1,3 +1,4 @@
+from __future__ import print_function
-+
import simplejson
import tempfile
import os
-@@ -309,7 +311,7 @@ def metgram(*args):
+@@ -309,7 +310,7 @@ def metgram(*args):
error = os.system(cmd)
if (error != 0):
- print "Error found"
-+ print("Error found")
++ print ("Error found")
f.close
-Index: magics++-2.24.4/python/Magics/setup.py.in
-===================================================================
---- magics++-2.24.4.orig/python/Magics/setup.py.in
-+++ magics++-2.24.4/python/Magics/setup.py.in
-@@ -1,5 +1,6 @@
- #!/usr/bin/env python
-
-+from __future__ import print_function
- from distutils.core import setup, Extension
- import os,sys
-
-@@ -34,13 +35,13 @@ attdict = dict(
- extra_objects = [],
- )
-
--add_attribute = lambda **args: [list.append(attdict[key],value) for key,value in args.items()]
-+add_attribute = lambda **args: [list.append(attdict[key],value) for key,value in list(args.items())]
-
- build_dir = '../'
-
- import glob
- ofiles=glob.glob("%s*.o" % build_dir)
--print "files are %s" % ofiles
-+print ("files are {}".format(ofiles))
- add_attribute(
- include_dirs = os.path.join(build_dir,'src')
- )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/magics.git
More information about the debian-science-commits
mailing list