From: Gilles DAVID Date: Fri, 31 Mar 2017 09:54:20 +0000 (+0200) Subject: Porting to python3 X-Git-Tag: V9_0_0~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6bcb9b0436b0a60d91ceafbcd0d3e0ccf4051764;p=tools%2Fyacsgen.git Porting to python3 --- diff --git a/Examples/ast1/components.py b/Examples/ast1/components.py index ff44750..bd8740c 100644 --- a/Examples/ast1/components.py +++ b/Examples/ast1/components.py @@ -23,7 +23,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,ASTERComponent,Service,F77Component aster_root=os.path.join(aster_home,aster_version) diff --git a/Examples/ast2/components.py b/Examples/ast2/components.py index 7932c77..941c2b3 100644 --- a/Examples/ast2/components.py +++ b/Examples/ast2/components.py @@ -23,7 +23,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,ASTERComponent,Service,F77Component aster_root=os.path.join(aster_home,aster_version) diff --git a/Examples/calcium1/components.py b/Examples/calcium1/components.py index 8311e46..3f81f37 100644 --- a/Examples/calcium1/components.py +++ b/Examples/calcium1/components.py @@ -19,7 +19,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,PYComponent,CPPComponent,F77Component from module_generator import Library diff --git a/Examples/calcium2/components.py b/Examples/calcium2/components.py index e89b9bc..c6fd48b 100644 --- a/Examples/calcium2/components.py +++ b/Examples/calcium2/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,PYComponent,CPPComponent,F77Component from module_generator import Library diff --git a/Examples/cpp1/components.py b/Examples/cpp1/components.py index 7004804..cbdd7ff 100644 --- a/Examples/cpp1/components.py +++ b/Examples/cpp1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,CPPComponent cwd=os.getcwd() diff --git a/Examples/cpp2/components.py b/Examples/cpp2/components.py index dc93752..cf00113 100644 --- a/Examples/cpp2/components.py +++ b/Examples/cpp2/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,CPPComponent cwd=os.getcwd() diff --git a/Examples/cppgui1/components.py b/Examples/cppgui1/components.py index 1e96db1..3300bac 100644 --- a/Examples/cppgui1/components.py +++ b/Examples/cppgui1/components.py @@ -18,7 +18,7 @@ # #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) import os from module_generator import * diff --git a/Examples/fort1/components.py b/Examples/fort1/components.py index 0a7e91b..539f27e 100644 --- a/Examples/fort1/components.py +++ b/Examples/fort1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,F77Component from module_generator import Library diff --git a/Examples/fort2/components.py b/Examples/fort2/components.py index 68c1953..cf64689 100644 --- a/Examples/fort2/components.py +++ b/Examples/fort2/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,F77Component cwd=os.getcwd() diff --git a/Examples/hxx1/test_compohxx.py b/Examples/hxx1/test_compohxx.py index a67be56..6af0552 100644 --- a/Examples/hxx1/test_compohxx.py +++ b/Examples/hxx1/test_compohxx.py @@ -11,43 +11,43 @@ import SALOME import salome salome.salome_init() -print "Test du composant CALCUL genere par hxx2salome" +print("Test du composant CALCUL genere par hxx2salome") import hxxcompos_ORB myCalc = salome.lcc.FindOrLoadComponent("FactoryServer", "CALCUL") -print "10+15 = ",myCalc.add(10,15) -print "10x15 = ",myCalc.mul(10,15) +print("10+15 = ",myCalc.add(10,15)) +print("10x15 = ",myCalc.mul(10,15)) #print "6! = ",myCalc.fact(6) res1,res2 = myCalc.sqr2(12.0) -print "12*12 = ",res1," ",res2 +print("12*12 = ",res1," ",res2) j=1 i1,i2,i3 = myCalc.return_3_int(j) assert (i1 == j+1),'Erreur dans la fonction return_3_int' assert (i2 == j+2),'Erreur dans la fonction return_3_int' assert (i3 == j+3),'Erreur dans la fonction return_3_int' -print 'return_3_int : ',j,' ',i1,' ',i2,' ',i3 -print "True && True = ",myCalc.And(True,True) -print "True && False = ",myCalc.And(True,False) -print "True || False = ",myCalc.Or(True,False) +print('return_3_int : ',j,' ',i1,' ',i2,' ',i3) +print("True && True = ",myCalc.And(True,True)) +print("True && False = ",myCalc.And(True,False)) +print("True || False = ",myCalc.Or(True,False)) from math import fabs assert (fabs(res1-144.0)<1.0e-6 ), 'Erreur dans la fonction myCalc.sqr2 : 12*12 = '+str(res1) assert ( myCalc.And(True,True)==True ) , 'Erreur dans la fonction And(True,True)' assert ( myCalc.And(True,False)==False ) , 'Erreur dans la fonction And(True,False)' assert ( myCalc.Or(True,False)==True ) , 'Erreur dans la fonction Or(True,False)' -print "Fin test hxx2salome/001/A1" +print("Fin test hxx2salome/001/A1") # myCoco = salome.lcc.FindOrLoadComponent("FactoryServerI", "ICOCO") # liste_champs = myCoco.getInputFieldsNames() nb_champs=len(liste_champs) -print "Nombre de champs = ",nb_champs +print("Nombre de champs = ",nb_champs) assert nb_champs == 2 , 'erreur dans le nombre de champs, different de 2!' # -print "Champ 1 (SourceField) : ",liste_champs[0] -print "Champ 2 (TargetField) : ",liste_champs[1] +print("Champ 1 (SourceField) : ",liste_champs[0]) +print("Champ 2 (TargetField) : ",liste_champs[1]) assert liste_champs[0] == "SourceField", 'erreur dans le nom du champ 1' assert liste_champs[1] == "TargetField", 'erreur dans le nom du champ 2' # -print "Fin test hxx2salome/ICOCO/A1" +print("Fin test hxx2salome/ICOCO/A1") myCoco1 = salome.lcc.FindOrLoadComponent("FactoryServerI1", "ICOCO") myCoco2 = salome.lcc.FindOrLoadComponent("FactoryServerI2", "ICOCO") # @@ -57,5 +57,5 @@ myCoco1.solve() #to test with 5.1.5 f=myCoco1.getOutputField("SourceField") myCoco2.printField(f) # -print "##################################" -print "Fin test hxx2salome/ICOCO/A2" +print("##################################") +print("Fin test hxx2salome/ICOCO/A2") diff --git a/Examples/paco1/components.py b/Examples/paco1/components.py index 1ed69ec..a7be2dd 100644 --- a/Examples/paco1/components.py +++ b/Examples/paco1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../pacocontext.py") +exec(compile(open("../pacocontext.py").read(), "../pacocontext.py", 'exec')) from module_generator import Generator,Module,Service,PACOComponent cwd=os.getcwd() diff --git a/Examples/paco2/components.py b/Examples/paco2/components.py index ff65bfd..8fd959a 100644 --- a/Examples/paco2/components.py +++ b/Examples/paco2/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../pacocontext.py") +exec(compile(open("../pacocontext.py").read(), "../pacocontext.py", 'exec')) from module_generator import Generator,Module,Service,PACOComponent cwd=os.getcwd() diff --git a/Examples/paco3/components.py b/Examples/paco3/components.py index eab10df..a3f4ab9 100644 --- a/Examples/paco3/components.py +++ b/Examples/paco3/components.py @@ -21,7 +21,7 @@ import os #import context from .. -execfile("../pacocontext.py") +exec(compile(open("../pacocontext.py").read(), "../pacocontext.py", 'exec')) from module_generator import Generator,Module,Service,PACOComponent cwd=os.getcwd() diff --git a/Examples/pydoc1/components.py b/Examples/pydoc1/components.py index f56fd8f..6a8fc90 100644 --- a/Examples/pydoc1/components.py +++ b/Examples/pydoc1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import * diff --git a/Examples/pygui1/components.py b/Examples/pygui1/components.py index 4491281..45dada3 100644 --- a/Examples/pygui1/components.py +++ b/Examples/pygui1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import * diff --git a/Examples/pygui1/pycomposGUI.py b/Examples/pygui1/pycomposGUI.py index e2e3d61..7917100 100644 --- a/Examples/pygui1/pycomposGUI.py +++ b/Examples/pygui1/pycomposGUI.py @@ -107,8 +107,8 @@ def CreateObject(): name = "%s_%d" % ( default_name, __objectid__ ) if not name: return getEngine().createObject( _getStudy(), name ) - print getEngine().s1(4,5) - print getEngine().ComponentDataType() + print(getEngine().s1(4,5)) + print(getEngine().ComponentDataType()) sg.updateObjBrowser( True ) class DemoImpl(QtWidgets.QDialog): @@ -125,7 +125,7 @@ class DemoImpl(QtWidgets.QDialog): # called when GUI action is activated # action ID is passed as parameter def OnGUIEvent( commandID ): - print "pycompos.OnGUIEvent(): command = %d" % commandID + print("pycompos.OnGUIEvent(): command = %d" % commandID) if commandID==941: widget=QMainWindow(sgPyQt.getDesktop()) web = QWebView(widget) diff --git a/Examples/pyth1/bidul.py b/Examples/pyth1/bidul.py index 285e064..2d09ee2 100644 --- a/Examples/pyth1/bidul.py +++ b/Examples/pyth1/bidul.py @@ -18,4 +18,4 @@ # def f(): - print "coucou" + print("coucou") diff --git a/Examples/pyth1/components.py b/Examples/pyth1/components.py index 2a9d235..4e95ae7 100644 --- a/Examples/pyth1/components.py +++ b/Examples/pyth1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,PYComponent cwd=os.getcwd() diff --git a/Examples/pyth2/components.py b/Examples/pyth2/components.py index 6cb4a4c..0a2ecbb 100644 --- a/Examples/pyth2/components.py +++ b/Examples/pyth2/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,PYComponent cwd=os.getcwd() diff --git a/Examples/test_compo.py b/Examples/test_compo.py index 02dd33f..1349bf5 100755 --- a/Examples/test_compo.py +++ b/Examples/test_compo.py @@ -17,7 +17,7 @@ class TestCompo(unittest.TestCase): #start salome and connect to it try: salome_module.main(["start", "-t"]) - except SystemExit, e: + except SystemExit as e: pass import runSession runSession.configureSession() @@ -44,7 +44,7 @@ class TestCompo(unittest.TestCase): xmlLoader = loader.YACSLoader() try: p = xmlLoader.load("coupling.xml") - except IOError,ex: + except IOError as ex: self.fail("IO exception:" + ex); self.assertTrue(p.isValid()) e = pilot.ExecutorSwig() @@ -54,7 +54,7 @@ class TestCompo(unittest.TestCase): def tearDown(self): try: salome_module.main(["killall"]) - except SystemExit, e: + except SystemExit as e: pass if __name__ == '__main__': diff --git a/Examples/types1/components.py b/Examples/types1/components.py index 5f05d72..d8484d3 100644 --- a/Examples/types1/components.py +++ b/Examples/types1/components.py @@ -20,7 +20,7 @@ import os #import context from .. -execfile("../context.py") +exec(compile(open("../context.py").read(), "../context.py", 'exec')) from module_generator import Generator,Module,Service,CPPComponent,PYComponent,add_type,add_module diff --git a/module_generator/__init__.py b/module_generator/__init__.py index 75e42b8..cd16304 100644 --- a/module_generator/__init__.py +++ b/module_generator/__init__.py @@ -22,15 +22,15 @@ The python module module_generator defines classes which can be used to define a generates a SALOME source module, its installation and a SALOME application including this module and other preexisting SALOME modules like GEOM, SMESH or others. """ -from gener import Module, Service, Generator -from fcompo import F77Component -from cppcompo import CPPComponent -from pacocompo import PACOComponent -from pycompo import PYComponent -from astcompo import ASTERComponent -from hxxcompo import HXX2SALOMEComponent -from hxxparacompo import HXX2SALOMEParaComponent -from yacstypes import add_type -from salomemodules import add_module -from gener import Library -from mpicompo import MPIComponent +from module_generator.gener import Module, Service, Generator +from module_generator.fcompo import F77Component +from module_generator.cppcompo import CPPComponent +from module_generator.pacocompo import PACOComponent +from module_generator.pycompo import PYComponent +from module_generator.astcompo import ASTERComponent +from module_generator.hxxcompo import HXX2SALOMEComponent +from module_generator.hxxparacompo import HXX2SALOMEParaComponent +from module_generator.yacstypes import add_type +from module_generator.salomemodules import add_module +from module_generator.gener import Library +from module_generator.mpicompo import MPIComponent diff --git a/module_generator/astcompo.py b/module_generator/astcompo.py index 03b32be..d6372ba 100644 --- a/module_generator/astcompo.py +++ b/module_generator/astcompo.py @@ -26,15 +26,15 @@ """ import re, os, sys -from gener import Component, Invalid, makedirs - -from pyth_tmpl import pyinitEXEService, pyinitCEXEService, pyinitService -import aster_tmpl -from aster_tmpl import asterCEXEService, asterEXEService -from aster_tmpl import asterService, asterEXECompo, asterCEXECompo, asterCompo -from aster_tmpl import comm, make_etude, cexe, exeaster -from aster_tmpl import container, component -from aster_tmpl import cmake_src_compo_aster, cmake_src_compo_aster_lib +from module_generator.gener import Component, Invalid, makedirs + +from module_generator.pyth_tmpl import pyinitEXEService, pyinitCEXEService, pyinitService +from module_generator import aster_tmpl +from module_generator.aster_tmpl import asterCEXEService, asterEXEService +from module_generator.aster_tmpl import asterService, asterEXECompo, asterCEXECompo, asterCompo +from module_generator.aster_tmpl import comm, make_etude, cexe, exeaster +from module_generator.aster_tmpl import container, component +from module_generator.aster_tmpl import cmake_src_compo_aster, cmake_src_compo_aster_lib class ASTERComponent(Component): """ diff --git a/module_generator/aster_tmpl.py b/module_generator/aster_tmpl.py index dd77ff1..91f7d71 100644 --- a/module_generator/aster_tmpl.py +++ b/module_generator/aster_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set asterCompo=""" import sys,traceback,os diff --git a/module_generator/cata_tmpl.py b/module_generator/cata_tmpl.py index 0fdafc6..6b84932 100644 --- a/module_generator/cata_tmpl.py +++ b/module_generator/cata_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set # CORBA idl diff --git a/module_generator/compat.py b/module_generator/compat.py index 672b33d..fd01532 100644 --- a/module_generator/compat.py +++ b/module_generator/compat.py @@ -38,10 +38,10 @@ def sorted(iterable, cmp=None, key=None, reverse=False) : d = {} for v in iterable : k = key(v) - if not d.has_key(k) : + if k not in d : d[k] = [] d[k].append(v) - keys = d.keys() + keys = list(d.keys()) keys.sort(cmp) i = [] for k in keys : @@ -78,9 +78,8 @@ class _TemplateMetaclass(type): cls.pattern = re.compile(pattern, re.IGNORECASE | re.VERBOSE) -class Template: +class Template(metaclass=_TemplateMetaclass): """A string class for supporting $-substitutions.""" - __metaclass__ = _TemplateMetaclass delimiter = '$' idpattern = r'[_a-z][_a-z0-9]*' diff --git a/module_generator/cpp_tmpl.py b/module_generator/cpp_tmpl.py index 1b3a897..2462e07 100644 --- a/module_generator/cpp_tmpl.py +++ b/module_generator/cpp_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set cxxCompo=""" #include "${component}.hxx" diff --git a/module_generator/cppcompo.py b/module_generator/cppcompo.py index 4d09676..75a9f08 100644 --- a/module_generator/cppcompo.py +++ b/module_generator/cppcompo.py @@ -22,15 +22,15 @@ """ import os -from gener import Component, Invalid -from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo -from cpp_tmpl import exeCPP, cmake_src_compo_cpp -from yacstypes import corba_rtn_type +from module_generator.gener import Component, Invalid +from module_generator.cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo +from module_generator.cpp_tmpl import exeCPP, cmake_src_compo_cpp +from module_generator.yacstypes import corba_rtn_type try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set class CPPComponent(Component): """ diff --git a/module_generator/doc_tmpl.py b/module_generator/doc_tmpl.py index bed1362..1d906e1 100644 --- a/module_generator/doc_tmpl.py +++ b/module_generator/doc_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set # CMakeLists.txt in doc directory # template parameters: diff --git a/module_generator/fcompo.py b/module_generator/fcompo.py index 03dbf45..4fcc90d 100644 --- a/module_generator/fcompo.py +++ b/module_generator/fcompo.py @@ -17,8 +17,8 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from gener import Component -from cppcompo import CPPComponent +from module_generator.gener import Component +from module_generator.cppcompo import CPPComponent import platform archi = platform.architecture()[0] diff --git a/module_generator/gener.py b/module_generator/gener.py index d164938..ce80d85 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -24,30 +24,30 @@ import warnings try: from string import Template except: - from compat import Template, set + from module_generator.compat import Template, set class Invalid(Exception): pass debug=0 -from mod_tmpl import * -from cata_tmpl import catalog, interface, idl -from cata_tmpl import xml, xml_interface, xml_service -from cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS -from cata_tmpl import idlMakefilePACO_salomepython_DATA, idlMakefilePACO_salomeidl_DATA -from cata_tmpl import idlMakefilePACO_INCLUDES -from cata_tmpl import cataOutStream, cataInStream, cataOutparam, cataInparam -from cata_tmpl import cataOutParallelStream, cataInParallelStream -from cata_tmpl import cataService, cataCompo +from module_generator.mod_tmpl import * +from module_generator.cata_tmpl import catalog, interface, idl +from module_generator.cata_tmpl import xml, xml_interface, xml_service +from module_generator.cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS +from module_generator.cata_tmpl import idlMakefilePACO_salomepython_DATA, idlMakefilePACO_salomeidl_DATA +from module_generator.cata_tmpl import idlMakefilePACO_INCLUDES +from module_generator.cata_tmpl import cataOutStream, cataInStream, cataOutparam, cataInparam +from module_generator.cata_tmpl import cataOutParallelStream, cataInParallelStream +from module_generator.cata_tmpl import cataService, cataCompo #from aster_tmpl import check_aster -from salomemodules import salome_modules -from yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type -from yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes -from yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies -from gui_tmpl import cmake_py_gui, pysalomeapp, cmake_cpp_gui, cppsalomeapp -from doc_tmpl import docmakefile, docconf, docsalomeapp -import yacsgen_version +from module_generator.salomemodules import salome_modules +from module_generator.yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type +from module_generator.yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes +from module_generator.yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies +from module_generator.gui_tmpl import cmake_py_gui, pysalomeapp, cmake_cpp_gui, cppsalomeapp +from module_generator.doc_tmpl import docmakefile, docconf, docsalomeapp +from module_generator import yacsgen_version def makedirs(namedir): """Create a new directory named namedir. If a directory already exists copy it to namedir.bak""" @@ -94,10 +94,10 @@ class Module(object): self.gui = gui try: self.validate() - except Invalid,e: + except Invalid as e: if debug: traceback.print_exc() - print "Error in module %s: %s" % (name,e) + print("Error in module %s: %s" % (name,e)) raise SystemExit def validate(self): @@ -175,8 +175,8 @@ class Component(object): cmake_vars = cmake_vars + salome_modules[mod]["linklibs"] else: default_lib = var_template.substitute(name=mod) - print "Unknown libraries for module " + mod - print "Using default library name " + default_lib + print("Unknown libraries for module " + mod) + print("Using default library name " + default_lib) cmake_vars = cmake_vars + default_lib + "\n " return cmake_text, cmake_vars @@ -252,7 +252,7 @@ class Component(object): """ def get_dependent_modules(mod,modules): modules.add(mod) - if salome_modules[mod].has_key("depends"): + if "depends" in salome_modules[mod]: for m in salome_modules[mod]["depends"]: if m not in modules: get_dependent_modules(m,modules) @@ -455,7 +455,7 @@ class Generator(object): srcs[compo.name] = fdict cmakecontent = "" - components_string = "".join(map(lambda x: x.name+" ", module.components)) + components_string = "".join([x.name+" " for x in module.components]) if self.module.gui: GUIname=module.name+"GUI" @@ -482,8 +482,7 @@ class Generator(object): cmake_gui="OFF" prefix = os.path.abspath(self.module.prefix) - component_libs = "".join(map(lambda x: x.libraryName()+" ", - module.components)) + component_libs = "".join([x.libraryName()+" " for x in module.components]) add_modules = "" for x in self.used_modules: cmake_text = cmake_find_module.substitute(module=x) @@ -539,11 +538,9 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) # other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc " include_template=Template("$${${module}_ROOT_DIR}/idl/salome") - opt_inc="".join(map(lambda x:include_template.substitute(module=x)+"\n ", - self.used_modules)) + opt_inc="".join([include_template.substitute(module=x)+"\n " for x in self.used_modules]) link_template=Template("$${${module}_SalomeIDL${module}}") - opt_link="".join(map(lambda x:link_template.substitute(module=x)+"\n ", - self.used_modules)) + opt_link="".join([link_template.substitute(module=x)+"\n " for x in self.used_modules]) idlfiles={"CMakeLists.txt":cmake_idl.substitute(module=module.name, extra_idl=other_idls, @@ -682,16 +679,13 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) elif src[-3:]==".ui": ui_files=ui_files+os.path.basename(src)+"\n " elif src[-3:]==".ts": - ts_files=ts_files+os.path.basename(src)+"\n " + ts_files = ts_files + os.path.basename(src) + "\n " else: other=other+os.path.basename(src)+"\n " - compo_dirs = "".join(map(lambda x: - "${PROJECT_SOURCE_DIR}/src/"+x.name+"\n ", - self.module.components)) + compo_dirs = "".join(["${PROJECT_SOURCE_DIR}/src/"+x.name+"\n " for x in self.module.components]) compo_dirs = compo_dirs + "${PROJECT_BINARY_DIR}/src/" + self.module.name + "GUI\n" - component_libs = "".join(map(lambda x: - x.libraryName()+" ", self.module.components)) + component_libs = "".join([x.libraryName()+" " for x in self.module.components]) makefile=cmake_cpp_gui.substitute(module=self.module.name, include_dirs=compo_dirs, libs=component_libs, @@ -713,19 +707,19 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) def makeMakefile(self,makefileItems): makefile="" - if makefileItems.has_key("header"): + if "header" in makefileItems: makefile=makefile + makefileItems["header"]+'\n' - if makefileItems.has_key("lib_LTLIBRARIES"): + if "lib_LTLIBRARIES" in makefileItems: makefile=makefile+"lib_LTLIBRARIES= "+" ".join(makefileItems["lib_LTLIBRARIES"])+'\n' - if makefileItems.has_key("salomepython_PYTHON"): + if "salomepython_PYTHON" in makefileItems: makefile=makefile+"salomepython_PYTHON= "+" ".join(makefileItems["salomepython_PYTHON"])+'\n' - if makefileItems.has_key("dist_salomescript_SCRIPTS"): + if "dist_salomescript_SCRIPTS" in makefileItems: makefile=makefile+"dist_salomescript_SCRIPTS= "+" ".join(makefileItems["dist_salomescript_SCRIPTS"])+'\n' - if makefileItems.has_key("salomeres_DATA"): + if "salomeres_DATA" in makefileItems: makefile=makefile+"salomeres_DATA= "+" ".join(makefileItems["salomeres_DATA"])+'\n' - if makefileItems.has_key("salomeinclude_HEADERS"): + if "salomeinclude_HEADERS" in makefileItems: makefile=makefile+"salomeinclude_HEADERS= "+" ".join(makefileItems["salomeinclude_HEADERS"])+'\n' - if makefileItems.has_key("body"): + if "body" in makefileItems: makefile=makefile+makefileItems["body"]+'\n' return makefile @@ -798,7 +792,7 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) # For PaCO++ def makexml(self): - from pacocompo import PACOComponent + from .pacocompo import PACOComponent interfaces = [] for compo in self.module.components: if isinstance(compo, PACOComponent): @@ -815,7 +809,7 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) dic key = file name to create dic value = file content or dictionary defining the content of a sub directory """ - for name, content in dic.items(): + for name, content in list(dic.items()): filename = os.path.join(basedir, name) if isinstance(content, str): fil = open(filename, 'w') @@ -912,14 +906,14 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) modules = [] if restrict: for mod in restrict: - if modules_dict.has_key(mod): + if mod in modules_dict: modules.append(modules_dict[mod]) else: - modules = modules_dict.values() + modules = list(modules_dict.values()) #add the alternate modules if given if altmodules: - for module, path in altmodules.items(): + for module, path in list(altmodules.items()): modules.append(' ' % (module, path)) #add the generated module @@ -965,4 +959,3 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) host = socket.gethostname().split('.')[0] fil.write(command % host) fil.close() - diff --git a/module_generator/gui_tmpl.py b/module_generator/gui_tmpl.py index 5b5237c..f16ed06 100644 --- a/module_generator/gui_tmpl.py +++ b/module_generator/gui_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set # SalomeApp.xml file for a python gui. # template parameters: diff --git a/module_generator/hxx_para_tmpl.py b/module_generator/hxx_para_tmpl.py index 1496c8c..f6b2537 100644 --- a/module_generator/hxx_para_tmpl.py +++ b/module_generator/hxx_para_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set cxxCompo=""" // this cxx file was generated by yacsgen diff --git a/module_generator/hxx_tmpl.py b/module_generator/hxx_tmpl.py index 48b7552..a5f5dfc 100644 --- a/module_generator/hxx_tmpl.py +++ b/module_generator/hxx_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set cxxCompo=""" // this cxx file was generated by yacsgen diff --git a/module_generator/hxx_tmpl_gui.py b/module_generator/hxx_tmpl_gui.py index cc5eff8..b54881f 100644 --- a/module_generator/hxx_tmpl_gui.py +++ b/module_generator/hxx_tmpl_gui.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set hxxgui_cxx=""" #include "${component_name}GUI.h" diff --git a/module_generator/hxxcompo.py b/module_generator/hxxcompo.py index 3202027..e02711d 100644 --- a/module_generator/hxxcompo.py +++ b/module_generator/hxxcompo.py @@ -23,24 +23,23 @@ debug=1 import os -import string import fnmatch from tempfile import mkstemp -from gener import Component, Invalid -from hxx_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxx +from module_generator.gener import Component, Invalid +from module_generator.hxx_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxx from module_generator import Service -from yacstypes import corba_rtn_type,moduleTypes -from hxx_awk import parse01,parse1,parse2,parse3 -from hxx_awk import cpp2idl_mapping +from module_generator.yacstypes import corba_rtn_type,moduleTypes +from module_generator.hxx_awk import parse01,parse1,parse2,parse3 +from module_generator.hxx_awk import cpp2idl_mapping # these tables contain the part of code which depends upon c++ types -from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c -from hxx_awk import cpp2yacs_mapping +from module_generator.hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c +from module_generator.hxx_awk import cpp2yacs_mapping from tempfile import mkdtemp -from hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts -from hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr -from hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en -from gener import Library -from gui_tmpl import cppsalomeapp +from module_generator.hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts +from module_generator.hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr +from module_generator.hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en +from module_generator.gener import Library +from module_generator.gui_tmpl import cppsalomeapp # ------------------------------------------------------------------------------ @@ -68,7 +67,7 @@ class HXX2SALOMEComponent(Component): f=os.popen(cmd1) class_name=f.readlines()[0] name=class_name - print "classname=",class_name + print("classname=",class_name) f.close() # create temporary awk files for the parsing @@ -129,7 +128,7 @@ class HXX2SALOMEComponent(Component): result_parsing=open("parse_type_result","r") for line in result_parsing.readlines(): line=line[0:-1] # get rid of trailing \n - words = string.split(line,';') + words = line.split(';') if len(words) >=3 and words[0] == "Function": # detect a new service function_name=words[2] @@ -165,10 +164,10 @@ class HXX2SALOMEComponent(Component): # - store it in service_definition[serv]["impl"] for serv in list_of_services: if debug: - print "service : ",serv - print " inports -> ",service_definition[serv]["inports"] - print " outports -> ",service_definition[serv]["outports"] - print " return -> ",service_definition[serv]["ret"] + print("service : ",serv) + print(" inports -> ",service_definition[serv]["inports"]) + print(" outports -> ",service_definition[serv]["outports"]) + print(" return -> ",service_definition[serv]["ret"]) # Part 1 : Argument pre-processing @@ -199,7 +198,7 @@ class HXX2SALOMEComponent(Component): post="" pre="" - if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 : + if cpp_impl_a[argtype].find("auto_ptr" ) != -1 : # for auto_ptr argument, retrieve the raw pointer behind post=".get()" if argtype == "const MEDMEM::MESH&" or \ @@ -229,7 +228,7 @@ class HXX2SALOMEComponent(Component): # Part 3.b : In Argument Post-processing for (argname,argtype) in service_definition[serv]["inports"]: # not all in types require a treatment - if cpp_impl_c.has_key(argtype): + if argtype in cpp_impl_c: format=cpp_impl_c[argtype] # id : treatment of %(module) is postponed in makecxx s_argument_postprocessing += \ @@ -251,7 +250,7 @@ class HXX2SALOMEComponent(Component): s_argument_postprocessing + \ s_rtn_processing if debug: - print "implementation :\n",service_definition[serv]["impl"] + print("implementation :\n",service_definition[serv]["impl"]) # # Create a list of Service objects (called services), @@ -288,13 +287,13 @@ class HXX2SALOMEComponent(Component): code=service_definition[serv]["impl"] if debug: - print "service : ",serv - print " inports -> ",service_definition[serv]["inports"] - print " converted inports -> ",inports - print " outports -> ",service_definition[serv]["outports"] - print " converted outports -> ",outports - print " Return -> ",service_definition[serv]["ret"] - print " converted Return -> ",Return + print("service : ",serv) + print(" inports -> ",service_definition[serv]["inports"]) + print(" converted inports -> ",inports) + print(" outports -> ",service_definition[serv]["outports"]) + print(" converted outports -> ",outports) + print(" Return -> ",service_definition[serv]["ret"]) + print(" converted Return -> ",Return) services.append(Service(serv, inport=inports, @@ -430,7 +429,7 @@ class HXX2SALOMEComponent(Component): defs = [] for serv in self.services: defs.append(serv.defs) - print "CNC bug : ",serv.body + print("CNC bug : ",serv.body) service = cxxService.substitute( component=self.name, service=serv.name, @@ -530,7 +529,7 @@ class HXX2SALOMEComponent(Component): def getIdlInterfaces(self): services = self.getIdlServices() - from hxx_tmpl import interfaceidlhxx + from .hxx_tmpl import interfaceidlhxx Inherited="" if self.use_medmem==True: Inherited="Engines::EngineComponent,SALOME::MultiCommClass,SALOME_MED::MED_Gen_Driver" diff --git a/module_generator/hxxparacompo.py b/module_generator/hxxparacompo.py index 059dbce..59c7b68 100644 --- a/module_generator/hxxparacompo.py +++ b/module_generator/hxxparacompo.py @@ -22,13 +22,12 @@ debug=1 import os -from gener import Component, Invalid -from hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxxpara +from module_generator.gener import Component, Invalid +from module_generator.hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxxpara from module_generator import Service -import string from tempfile import mkstemp -from yacstypes import corba_rtn_type,moduleTypes -from gener import Library +from module_generator.yacstypes import corba_rtn_type,moduleTypes +from module_generator.gener import Library class HXX2SALOMEParaComponent(Component): def __init__(self, hxxfile , cpplib , cpp_path ): @@ -49,12 +48,12 @@ class HXX2SALOMEParaComponent(Component): self.hxxfile=hxxfile # to include it in servant implementation # grab name of c++ component - from hxx_awk import parse01,parse1,parse2,parse3 + from .hxx_awk import parse01,parse1,parse2,parse3 cmd1="""awk '$1 == "class" && $0 !~ /;/ {print $2}' """ + hxxfileful[0] + """|awk -F: '{printf "%s",$1}' """ f=os.popen(cmd1) class_name=f.readlines()[0] name=class_name - print "classname=",class_name + print("classname=",class_name) if cpplib[:3]=="lib" and cpplib[-3:]==".so": cpplibname=cpplib[3:-3] # get rid of lib and .so, to use within makefile.am @@ -101,8 +100,8 @@ class HXX2SALOMEParaComponent(Component): # ... # The service names are stored in list_of_services # The information relative to a service (called service_name) is stored in the dictionnary service_definition[service_name] - from hxx_awk import cpp2idl_mapping - from hxx_awk import cpp2yacs_mapping + from .hxx_awk import cpp2idl_mapping + from .hxx_awk import cpp2yacs_mapping cpp2yacs_mapping["const MEDCoupling::MEDCouplingFieldDouble*"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" cpp2yacs_mapping["const MEDCoupling::MEDCouplingFieldDouble&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" cpp2yacs_mapping["MEDCoupling::MEDCouplingFieldDouble*&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" @@ -112,7 +111,7 @@ class HXX2SALOMEParaComponent(Component): result_parsing=open("parse_type_result","r") for line in result_parsing.readlines(): line=line[0:-1] # get rid of trailing \n - words = string.split(line,';') + words = line.split(';') if len(words) >=3 and words[0] == "Function": # detect a new service function_name=words[2] @@ -140,19 +139,19 @@ class HXX2SALOMEParaComponent(Component): else: service_definition[list_of_services[-1]]["outports"].append( (argname,typename) ) - if service_definition.has_key('getInputFieldTemplate'): + if 'getInputFieldTemplate' in service_definition: del service_definition['getInputFieldTemplate'] # # generate implementation of c++ servant # store it in service_definition[serv]["impl"] # - from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types + from .hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types cpp_impl_b["MEDCoupling::MEDCouplingFieldDouble*"]="""\tMEDCoupling::MPIMEDCouplingFieldDoubleServant * _rtn_field_i = new MEDCoupling::MPIMEDCouplingFieldDoubleServant(_orb,_poa,this,_rtn_cpp); \t_rtn_cpp->decrRef(); \tSALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n""" cpp_impl_a["const MEDCoupling::MEDCouplingFieldDouble*"]="\tMEDCoupling::MEDCouplingFieldDouble* _%(arg)s=cppCompo_->getInputFieldTemplate();\n\t_setInputField(%(arg)s,_%(arg)s);\n\t_initializeCoupling(%(arg)s);\n" - from yacstypes import corbaTypes,corbaOutTypes + from .yacstypes import corbaTypes,corbaOutTypes format_thread_signature="void * th_%s(void * st);" # this thread declaration will be included in servant's header format_thread_struct="typedef struct {\n int ip;\n Engines::IORTab* tior;\n%(arg_decl)s} thread_%(serv_name)s_str;" # this thread declaration will be included in servant's header format_thread_create=""" @@ -219,10 +218,10 @@ void *th_%(serv_name)s(void *s) self.thread_impl="" # the implementation of the thread functions used to invoque services on slave processors for serv in list_of_services: if debug: - print "service : ",serv - print " inports -> ",service_definition[serv]["inports"] - print " outports -> ",service_definition[serv]["outports"] - print " return -> ",service_definition[serv]["ret"] + print("service : ",serv) + print(" inports -> ",service_definition[serv]["inports"]) + print(" outports -> ",service_definition[serv]["outports"]) + print(" return -> ",service_definition[serv]["ret"]) # Part 0 : specific treatments for parallel components (call threads to forward the invocation to the service to all processes) service_definition[serv]["thread_func_decl"]=format_thread_signature % serv @@ -273,7 +272,7 @@ void *th_%(serv_name)s(void *s) # special treatment for some arguments post="" pre="" - if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 : + if cpp_impl_a[argtype].find("auto_ptr" ) != -1 : post=".get()" # for auto_ptr argument, retrieve the raw pointer behind if argtype == "const MEDMEM::MESH&" or argtype == "const MEDMEM::SUPPORT&" : pre="*" # we cannot create MESHClient on the stack (private constructor), so we create it on the heap and dereference it @@ -291,7 +290,7 @@ void *th_%(serv_name)s(void *s) # because we don't know here the module name # Part 3.b : In Argument Post-processing for (argname,argtype) in service_definition[serv]["inports"]: - if cpp_impl_c.has_key(argtype): # not all in types require a treatment + if argtype in cpp_impl_c: # not all in types require a treatment format=cpp_impl_c[argtype] s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # id : treatment of %(module) is postponed in makecxx @@ -302,7 +301,7 @@ void *th_%(serv_name)s(void *s) service_definition[serv]["impl"] = s_thread_call + s_argument_processing + s_call_cpp_function + s_thread_join + s_argument_postprocessing + s_rtn_processing if debug: - print "implementation :\n",service_definition[serv]["impl"] + print("implementation :\n",service_definition[serv]["impl"]) # # Create a list of Service objects (called services), and give it to Component constructor @@ -337,13 +336,13 @@ void *th_%(serv_name)s(void *s) code=service_definition[serv]["impl"] if debug: - print "service : ",serv - print " inports -> ",service_definition[serv]["inports"] - print " converted inports -> ",inports - print " outports -> ",service_definition[serv]["outports"] - print " converted outports -> ",outports - print " Return -> ",service_definition[serv]["ret"] - print " converted Return -> ",Return + print("service : ",serv) + print(" inports -> ",service_definition[serv]["inports"]) + print(" converted inports -> ",inports) + print(" outports -> ",service_definition[serv]["outports"]) + print(" converted outports -> ",outports) + print(" Return -> ",service_definition[serv]["ret"]) + print(" converted Return -> ",Return) services.append(Service(serv, inport=inports, @@ -441,10 +440,10 @@ void *th_%(serv_name)s(void *s) thread_func_decl="\n".join(self.thread_func_decl) thread_str_decl="\n".join(self.thread_str_decl) if debug: - print "thread_func_decl : " - print thread_func_decl - print "thread_str_decl : " - print thread_str_decl + print("thread_func_decl : ") + print(thread_func_decl) + print("thread_str_decl : ") + print(thread_str_decl) if self.inheritedclass: inheritedclass= " public virtual " + self.inheritedclass + "," @@ -473,7 +472,7 @@ void *th_%(serv_name)s(void *s) def getIdlInterfaces(self): services = self.getIdlServices() - from hxx_tmpl import interfaceidlhxx + from .hxx_tmpl import interfaceidlhxx Inherited="" Inherited="SALOME_MED::ParaMEDMEMComponent" return interfaceidlhxx.substitute(component=self.name,inherited=Inherited, services="\n".join(services)) diff --git a/module_generator/mod_tmpl.py b/module_generator/mod_tmpl.py index 793377a..55ef07c 100644 --- a/module_generator/mod_tmpl.py +++ b/module_generator/mod_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set application=""" diff --git a/module_generator/mpi_tmpl.py b/module_generator/mpi_tmpl.py index c393c1c..cc51bd0 100644 --- a/module_generator/mpi_tmpl.py +++ b/module_generator/mpi_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set # cxx file of a MPI component. # template parameters: diff --git a/module_generator/mpicompo.py b/module_generator/mpicompo.py index 5703a90..b060c52 100644 --- a/module_generator/mpicompo.py +++ b/module_generator/mpicompo.py @@ -22,17 +22,17 @@ """ import os -from gener import Component, Invalid -from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo -from cpp_tmpl import exeCPP, cmake_src_compo_cpp -from yacstypes import corba_rtn_type, corba_in_type -import mpi_tmpl -from cppcompo import CPPComponent +from module_generator.gener import Component, Invalid +from module_generator.cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo +from module_generator.cpp_tmpl import exeCPP, cmake_src_compo_cpp +from module_generator.yacstypes import corba_rtn_type, corba_in_type +from module_generator import mpi_tmpl +from module_generator.cppcompo import CPPComponent try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set class MPIComponent(CPPComponent): """ diff --git a/module_generator/paco_tmpl.py b/module_generator/paco_tmpl.py index 064b260..bcf190d 100644 --- a/module_generator/paco_tmpl.py +++ b/module_generator/paco_tmpl.py @@ -24,7 +24,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set compoMakefile=""" include $$(top_srcdir)/adm_local/make_common_starter.am diff --git a/module_generator/pacocompo.py b/module_generator/pacocompo.py index 7950e3d..4a895f6 100644 --- a/module_generator/pacocompo.py +++ b/module_generator/pacocompo.py @@ -25,14 +25,14 @@ Module that defines PACOComponent for SALOME PaCO++ components implemented in C++ """ import os -from gener import Component, Invalid -from paco_tmpl import compoMakefile, hxxCompo, cxxService -from paco_tmpl import initService, cxxCompo, paco_sources -from paco_tmpl import cxxFactoryDummy, cxxFactoryMpi, cxx_des_parallel_stream -from paco_tmpl import hxxparallel_instream, hxxparallel_outstream, hxxinit_ok -from paco_tmpl import hxxparallel_instream_init, hxxparallel_outstream_init, cxxService_connect -from paco_tmpl import cxx_cons_service, cxx_cons_parallel_outstream, cxx_cons_parallel_instream -from cata_tmpl import parallel_interface +from module_generator.gener import Component, Invalid +from module_generator.paco_tmpl import compoMakefile, hxxCompo, cxxService +from module_generator.paco_tmpl import initService, cxxCompo, paco_sources +from module_generator.paco_tmpl import cxxFactoryDummy, cxxFactoryMpi, cxx_des_parallel_stream +from module_generator.paco_tmpl import hxxparallel_instream, hxxparallel_outstream, hxxinit_ok +from module_generator.paco_tmpl import hxxparallel_instream_init, hxxparallel_outstream_init, cxxService_connect +from module_generator.paco_tmpl import cxx_cons_service, cxx_cons_parallel_outstream, cxx_cons_parallel_instream +from module_generator.cata_tmpl import parallel_interface class PACOComponent(Component): diff --git a/module_generator/pycompo.py b/module_generator/pycompo.py index 85cf820..1879666 100644 --- a/module_generator/pycompo.py +++ b/module_generator/pycompo.py @@ -21,8 +21,8 @@ Module that defines PYComponent for SALOME components implemented in Python """ import os -from gener import Component, Invalid -from pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo, cmake_src_compo_py +from module_generator.gener import Component, Invalid +from module_generator.pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo, cmake_src_compo_py import textwrap from string import split,rstrip,join @@ -30,7 +30,7 @@ def indent(text, prefix=' '): """Indent text by prepending a given prefix to each line.""" if not text: return '' lines = split(text, '\n') - lines = map(lambda line, prefix=prefix: prefix + line, lines) + lines = list(map(lambda line, prefix=prefix: prefix + line, lines)) if lines: lines[-1] = rstrip(lines[-1]) return join(lines, '\n') @@ -99,8 +99,7 @@ class PYComponent(Component): raise Invalid("Invalid kind ()%s for component %s" % ( self.kind, self.name)) - sources = pyfile + "".join(map(lambda x: "\n " + os.path.basename(x), - self.sources)) + sources = pyfile + "".join(["\n " + os.path.basename(x) for x in self.sources]) cmake_content = cmake_src_compo_py.substitute(sources=sources) return {"CMakeLists.txt":cmake_content, diff --git a/module_generator/pyth_tmpl.py b/module_generator/pyth_tmpl.py index e819913..a5d86a1 100644 --- a/module_generator/pyth_tmpl.py +++ b/module_generator/pyth_tmpl.py @@ -20,7 +20,7 @@ try: from string import Template except: - from compat import Template,set + from module_generator.compat import Template,set pyCompo=""" import sys,traceback,os diff --git a/module_generator/yacstypes.py b/module_generator/yacstypes.py index abb2c5d..6379484 100644 --- a/module_generator/yacstypes.py +++ b/module_generator/yacstypes.py @@ -62,7 +62,7 @@ def corba_rtn_type(typ, module): else: return corbaRtnTypes[typ] -ValidTypes = corbaTypes.keys() +ValidTypes = list(corbaTypes.keys()) PyValidTypes = ValidTypes+["pyobj"] def add_type(typename, corbaType=None, corbaOutType=None, module="", idltype=None, corbaRtnType=None): @@ -102,8 +102,8 @@ DatastreamParallelTypes = {"Param_Double_Port":"Param_Double_Port"} ValidImpl = ("CPP", "PY", "F77", "ASTER", "PACO") ValidImplTypes = ("sequential", "parallel") -ValidStreamTypes = calciumTypes.keys() -ValidParallelStreamTypes = DatastreamParallelTypes.keys() +ValidStreamTypes = list(calciumTypes.keys()) +ValidParallelStreamTypes = list(DatastreamParallelTypes.keys()) ValidDependencies = ("I", "T") #Add KERNEL YACS types : YACS name, c++ corba arg in, c++ corba arg out,defining module, repr corba idl, c++ corba return diff --git a/script/hxx2salome.py b/script/hxx2salome.py index 053e697..6fda8ed 100755 --- a/script/hxx2salome.py +++ b/script/hxx2salome.py @@ -80,21 +80,21 @@ def main(): # Make sure given paths/files are valid if not os.path.exists(cppdir): - print "ERROR: cppdir %s does not exist. It is mandatory" % cppdir - print usage + print("ERROR: cppdir %s does not exist. It is mandatory" % cppdir) + print(usage) sys.exit(1) if not os.path.exists(installpath): - print "ERROR: installpath %s does not exist. It is mandatory" \ - % installpath - print usage + print("ERROR: installpath %s does not exist. It is mandatory" \ + % installpath) + print(usage) sys.exit(1) if options.environ_file != None: if not os.path.exists(options.environ_file): - print "ERROR: environ_file %s does not exist. It is mandatory" \ - % options.environ_file - print usage + print("ERROR: environ_file %s does not exist. It is mandatory" \ + % options.environ_file) + print(usage) sys.exit(1) hxx2salome(cppdir=cppdir, @@ -141,7 +141,7 @@ def hxx2salome(cppdir, try: os.mkdir(install_root_dir) except OSError: - print "Warning : directory %s already exixts!" % install_root_dir + print("Warning : directory %s already exixts!" % install_root_dir) # if a graphical user interface is required, # ask HXX2SALOMEComponent to generate template files