X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_SWIG%2FGEOM_TestField.py;h=ee4351c1a1cbe1fb8c42c153ba28b47970b35790;hb=b6f0965afb72083a5234f9b4fb0b233adaaf8d9d;hp=a155398275fa82e75ffbc9692d38b57734dcd6a7;hpb=4e4b3762fc1215eb520840fe65eaeeea0854eff8;p=modules%2Fgeom.git diff --git a/src/GEOM_SWIG/GEOM_TestField.py b/src/GEOM_SWIG/GEOM_TestField.py index a15539827..ee4351c1a 100644 --- a/src/GEOM_SWIG/GEOM_TestField.py +++ b/src/GEOM_SWIG/GEOM_TestField.py @@ -1,23 +1,23 @@ - # Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE - # - # This library is free software; you can redistribute it and/or - # modify it under the terms of the GNU Lesser General Public - # License as published by the Free Software Foundation; either - # version 2.1 of the License, or (at your option) any later version. - # - # This library is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # Lesser General Public License for more details. - # - # You should have received a copy of the GNU Lesser General Public - # License along with this library; if not, write to the Free Software - # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - # - # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com - # - - # Python API for field on geometry manipulations: +# Copyright (C) 2013-2022 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Python API for field on geometry manipulations: # field = geompy.CreateField(shape, name, type, dimension, componentNames) # geompy.RemoveField(field) @@ -44,16 +44,16 @@ MustFail = -1 geompy = None def CheckFieldCreation(shape, name, ftype, dimension, componentNames, nbFiOrMustFail=-1): - # WARNING: assure name uniquness to check geompy.GetField( shape, name ) + # WARNING: assure name uniqueness to check geompy.GetField( shape, name ) try: field = geompy.CreateField(shape, name, ftype, dimension, componentNames) - except Exception, e: + except Exception as e: if nbFiOrMustFail == MustFail: - print "Ok, expected exception caught: %s"%e + print("Ok, expected exception caught: %s"%e) return raise e if nbFiOrMustFail == MustFail: - raise RuntimeError, "Expected exception NOT thrown" + raise RuntimeError("Expected exception NOT thrown") assert field.getShape() assert field.getShape().IsSame( shape ) assert field.getName() == name @@ -70,13 +70,13 @@ def CheckFieldCreation(shape, name, ftype, dimension, componentNames, nbFiOrMust def CheckStepManips(field, step, stamp, values, nbStepsOrMustFail, toRemove=False): try: stp = field.addStep(step, stamp, values) - except Exception, e: + except Exception as e: if nbStepsOrMustFail == MustFail: - print "Ok, expected exception caught: %s"%e + print("Ok, expected exception caught: %s"%e) return raise e if nbStepsOrMustFail == MustFail: - raise RuntimeError, "Expected exception NOT thrown" + raise RuntimeError("Expected exception NOT thrown") assert field.countSteps() == nbStepsOrMustFail assert len( field.getSteps() ) == nbStepsOrMustFail assert step in field.getSteps() @@ -138,12 +138,12 @@ def TestField (geomBuilder, math): CheckStepManips( bfield, 2, -2, [1,0]*4, 1 ) # int field on 6 faces ifield = geompy.CreateField(shape, "intF", GEOM.FDT_Int, 2, ["id","domain"]) - CheckStepManips( ifield, -1, -10, range(12), 1 ) - CheckStepManips( ifield, -2, -20, range(6)*2, 2 ) + CheckStepManips( ifield, -1, -10, list(range(12)), 1 ) + CheckStepManips( ifield, -2, -20, list(range(6))*2, 2 ) # double field on a solid dfield = geompy.CreateField(shape, "dblS", GEOM.FDT_Double, 3, ["a","b","c"]) CheckStepManips( dfield, -1, -10, [-1.1, 2.3, 4000], 1 ) - CheckStepManips( dfield, -2, -20, range(3), 2 ) + CheckStepManips( dfield, -2, -20, list(range(3)), 2 ) # assert exception in case of invalid parameters CheckStepManips( sfield, -1, -10, ["25 Sep","2013"], MustFail ) # step already exists @@ -159,7 +159,7 @@ def TestField (geomBuilder, math): # dump the study import salome assert( salome.myStudy.DumpStudy(os.path.dirname(dumpFile), os.path.basename(dumpFile), 1, 0)) - execfile( pyFile ) + exec(compile(open( pyFile ).read(), pyFile, 'exec')) os.remove( pyFile ) - print "Field manipulations work OK" + print("Field manipulations work OK")