From: rnv Date: Wed, 24 May 2017 07:35:26 +0000 (+0300) Subject: Python3 porting: 1-st draft version. X-Git-Tag: V9_0_0~2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7c00c7fc1db6fdbcadf3d5e953bdce41cab9ac89;hp=1b13bcad7fe398f1b2a9f51da379ec6c17636ff5;p=samples%2Fpycalculator.git Python3 porting: 1-st draft version. --- diff --git a/src/PYCALCULATOR/PYCALCULATOR.py b/src/PYCALCULATOR/PYCALCULATOR.py index 4ad9a14..369fc2a 100755 --- a/src/PYCALCULATOR/PYCALCULATOR.py +++ b/src/PYCALCULATOR/PYCALCULATOR.py @@ -47,7 +47,7 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA def __init__(self, orb, poa, contID, containerName, instanceName, interfaceName): - if verbose(): print "Begin of PYCALCULATOR::__init__" + if verbose(): print("Begin of PYCALCULATOR::__init__") SALOME_ComponentPy.SALOME_ComponentPy_i.__init__( self, @@ -59,9 +59,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA interfaceName, # component interface name False) # notification flag (for notification server) - self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i(self._orb) + self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i(self._orb) - if verbose(): print "End of PYCALCULATOR::__init__" + if verbose(): print("End of PYCALCULATOR::__init__") pass @@ -75,8 +75,8 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA self.beginService("PYCALCULATOR::Clone") if verbose(): - print "Begin of PYCALCULATOR::Clone" - print " field : ", field + print("Begin of PYCALCULATOR::Clone") + print(" field : ", field) pass frescorba = None @@ -88,12 +88,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA # create CORBA field frescorba = MEDCouplingFieldDoubleServant._this(f) - except Exception, e: - if verbose(): print e + except Exception as e: + if verbose(): print(e) pass if verbose(): - print "End of PYCALCULATOR::Clone" + print("End of PYCALCULATOR::Clone") pass self.endService("PYCALCULATOR::Clone") @@ -105,9 +105,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA self.beginService("PYCALCULATOR::Add") if verbose(): - print "Begin of PYCALCULATOR::Add" - print " field 1 : ", field1 - print " field 2 : ", field2 + print("Begin of PYCALCULATOR::Add") + print(" field 1 : ", field1) + print(" field 2 : ", field2) pass frescorba = None @@ -124,12 +124,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA # create CORBA field frescorba = MEDCouplingFieldDoubleServant._this(fres) - except Exception, e: - if verbose(): print e + except Exception as e: + if verbose(): print(e) pass if verbose(): - print "End of PYCALCULATOR::Add" + print("End of PYCALCULATOR::Add") pass self.endService("PYCALCULATOR::Add") @@ -141,9 +141,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA self.beginService("PYCALCULATOR::Mul") if verbose(): - print "Begin of PYCALCULATOR::Mul" - print " field 1 : ", field1 - print " field 2 : ", field2 + print("Begin of PYCALCULATOR::Mul") + print(" field 1 : ", field1) + print(" field 2 : ", field2) pass frescorba = None @@ -160,12 +160,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA # create CORBA field frescorba = MEDCouplingFieldDoubleServant._this(fres) - except Exception, e: - if verbose(): print e + except Exception as e: + if verbose(): print(e) pass if verbose(): - print "End of PYCALCULATOR::Mul" + print("End of PYCALCULATOR::Mul") pass self.endService("PYCALCULATOR::Mul") @@ -177,9 +177,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA self.beginService("PYCALCULATOR::AddConstant") if verbose(): - print "Begin of PYCALCULATOR::AddConstant" - print " field : ", field - print " constant : ", val + print("Begin of PYCALCULATOR::AddConstant") + print(" field : ", field) + print(" constant : ", val) pass frescorba = None @@ -194,12 +194,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA # create CORBA field frescorba = MEDCouplingFieldDoubleServant._this(fres) - except Exception, e: - if verbose(): print e + except Exception as e: + if verbose(): print(e) pass if verbose(): - print "End of PYCALCULATOR::AddConstant" + print("End of PYCALCULATOR::AddConstant") pass self.endService("PYCALCULATOR::AddConstant") @@ -211,9 +211,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA self.beginService("PYCALCULATOR::MulConstant") if verbose(): - print "Begin of PYCALCULATOR::MulConstant" - print " field : ", field - print " constant : ", val + print("Begin of PYCALCULATOR::MulConstant") + print(" field : ", field) + print(" constant : ", val) pass frescorba = None @@ -228,12 +228,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA # create CORBA field frescorba = MEDCouplingFieldDoubleServant._this(fres) - except Exception, e: - if verbose(): print e + except Exception as e: + if verbose(): print(e) pass if verbose(): - print "End of PYCALCULATOR::MulConstant" + print("End of PYCALCULATOR::MulConstant") pass self.endService("PYCALCULATOR::MulConstant") diff --git a/src/PYCALCULATOR/PYCALCULATOR_TEST.py b/src/PYCALCULATOR/PYCALCULATOR_TEST.py index e0a3a1a..4f5d966 100755 --- a/src/PYCALCULATOR/PYCALCULATOR_TEST.py +++ b/src/PYCALCULATOR/PYCALCULATOR_TEST.py @@ -42,7 +42,7 @@ pc = salome.lcc.FindOrLoadComponent('FactoryServer','PYCALCULATOR') medFile = os.path.join(os.getenv("DATA_DIR"), "MedFiles", "pointe.med") meshName = "maa1" fieldName = "fieldcelldoublevector" -print medFile, meshName, fieldName +print(medFile, meshName, fieldName) f = ReadFieldCell(medFile, meshName, 0, fieldName, -1, -1) forig = MEDCouplingFieldDoubleServant._this(f) @@ -60,9 +60,9 @@ clt_f2 = MEDCouplingFieldDoubleClient.New(f2) clt_f3 = MEDCouplingFieldDoubleClient.New(f3) clt_f4 = MEDCouplingFieldDoubleClient.New(f4) -print "clt_forig:", clt_forig -print "clt_fcopy:", clt_fcopy -print "clt_f1:", clt_f1 -print "clt_f2:", clt_f2 -print "clt_f3:", clt_f3 -print "clt_f4:", clt_f4 +print("clt_forig:", clt_forig) +print("clt_fcopy:", clt_fcopy) +print("clt_f1:", clt_f1) +print("clt_f2:", clt_f2) +print("clt_f3:", clt_f3) +print("clt_f4:", clt_f4)