Salome HOME
Porting to python3
authorGilles DAVID <gilles-g.david@edf.fr>
Fri, 31 Mar 2017 09:54:20 +0000 (11:54 +0200)
committerGilles DAVID <gilles-g.david@edf.fr>
Fri, 31 Mar 2017 09:54:20 +0000 (11:54 +0200)
46 files changed:
Examples/ast1/components.py
Examples/ast2/components.py
Examples/calcium1/components.py
Examples/calcium2/components.py
Examples/cpp1/components.py
Examples/cpp2/components.py
Examples/cppgui1/components.py
Examples/fort1/components.py
Examples/fort2/components.py
Examples/hxx1/test_compohxx.py
Examples/paco1/components.py
Examples/paco2/components.py
Examples/paco3/components.py
Examples/pydoc1/components.py
Examples/pygui1/components.py
Examples/pygui1/pycomposGUI.py
Examples/pyth1/bidul.py
Examples/pyth1/components.py
Examples/pyth2/components.py
Examples/test_compo.py
Examples/types1/components.py
module_generator/__init__.py
module_generator/astcompo.py
module_generator/aster_tmpl.py
module_generator/cata_tmpl.py
module_generator/compat.py
module_generator/cpp_tmpl.py
module_generator/cppcompo.py
module_generator/doc_tmpl.py
module_generator/fcompo.py
module_generator/gener.py
module_generator/gui_tmpl.py
module_generator/hxx_para_tmpl.py
module_generator/hxx_tmpl.py
module_generator/hxx_tmpl_gui.py
module_generator/hxxcompo.py
module_generator/hxxparacompo.py
module_generator/mod_tmpl.py
module_generator/mpi_tmpl.py
module_generator/mpicompo.py
module_generator/paco_tmpl.py
module_generator/pacocompo.py
module_generator/pycompo.py
module_generator/pyth_tmpl.py
module_generator/yacstypes.py
script/hxx2salome.py

index ff447501f0716fba24a38eb72cf0c2789289ffd5..bd8740c45c6714309e02969a701623592e99175f 100644 (file)
@@ -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)
index 7932c7764ff83361d34e6fc5289e807958827a19..941c2b3760c789b15a43ee1c3914a3821d6de0dc 100644 (file)
@@ -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)
index 8311e462f9d57ac9c658a66fbabe90a72b541c55..3f81f377e0bf91cbf92bf53dcb152994d61fffcc 100644 (file)
@@ -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
 
index e89b9bc9dc8604032f40b50cd9972547ba0e97ca..c6fd48b576f1306ca7fa6777882f81654d9a147a 100644 (file)
@@ -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
 
index 70048043a695f0fcbf642cd98bad6d9eb8541ff1..cbdd7ffc53299537b91b82666281c0ebb0ed58b2 100644 (file)
@@ -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()
index dc937520ee4f944c87787b9e141918cf0d377451..cf00113150110cb025638d98e0b31c15388b13fc 100644 (file)
@@ -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()
index 1e96db18c589691b0ec293968cb2e86df513f398..3300bace21984f7577a47be336746a7995aea7e2 100644 (file)
@@ -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 *
index 0a7e91b26c4d086690bb4c249a3a0f699255b817..539f27e43c20612f765685ca1a3b7fde69ad4f53 100644 (file)
@@ -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
 
index 68c1953fe0a9abcb920133108f97cff166fc0ac4..cf646896dc267d3ac0d044878c3ff0f58dc345bb 100644 (file)
@@ -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()
index a67be5691010d6739b92dbe9e721d901ed1de55e..6af0552d34c43ddb566b66144e72984bb5e9af93 100644 (file)
 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")
index 1ed69ecc07a31537dec5050cd7c1b037004e52bf..a7be2dd4a4ce86c111ef24d069d3a3f6f5509ae7 100644 (file)
@@ -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()
index ff65bfdfa81fed5fe1d008c197892ff38992b462..8fd959ab57da528b45b12df94def58a685b8c6af 100644 (file)
@@ -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()
index eab10df341be6435ee70125df5d7ccc535d53e94..a3f4ab98f37662dab760df9199d88a2bde31d1ea 100644 (file)
@@ -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()
index f56fd8fccdcd2fc6b8890e59bd1702dcc5434730..6a8fc904024f003b192613af17898e4c9ae17f85 100644 (file)
@@ -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 *
 
index 44912810e608f1c8c1833f1baad7c62d4b87f967..45dada315fe51c2b56ecf19f8d2a6b7303173d6c 100644 (file)
@@ -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 *
 
index e2e3d61d37d853d813b171243eb92016fbe7804f..7917100853f8eacb00b1fc1f0e1f0196c3dc76fc 100644 (file)
@@ -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)
index 285e064c4eb0d4f690754c0912ca7fe2d158cf68..2d09ee2b957402ca8ebdc570e7e541bf35be9de7 100644 (file)
@@ -18,4 +18,4 @@
 #
 
 def f():
-  print "coucou"
+  print("coucou")
index 2a9d235512ad90406099c468241fc356e58af556..4e95ae71cfb1fb95eda3c8d6bedfe08d5ec69ed5 100644 (file)
@@ -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()
index 6cb4a4c5feac725524d0a9852536bb16f84597e6..0a2ecbb0ec68671eb3f5dea6cf1b378ba161ff97 100644 (file)
@@ -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()
index 02dd33f66c46e440e320f2fda0dfcaad59c0b1e0..1349bf505b006a9511c86108d491c72ee6ad5d68 100755 (executable)
@@ -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__':
index 5f05d722c2823ce011cb2d04e36ca6ba49debb60..d8484d306de0dae60c9c134acc9146bd9bb9deb2 100644 (file)
@@ -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
 
index 75e42b8f6a05807c1fa716fcbfbe44fc777b9a23..cd16304ae1b278cc66cff3e387952a45f7151d15 100644 (file)
@@ -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
index 03b32be2a2492224680ad5523ac007f22cd795b1..d6372ba3963ea92ffddbb3aa16553e84a0ccc420 100644 (file)
 """
 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):
   """
index dd77ff1f116a2026f8b9a2f1f89cfd54ed8db6ca..91f7d715907e7cfae3ad029c1926258a51650a12 100644 (file)
@@ -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
index 0fdafc64e09a9d6ab038c7bafe5f515e4fdc750a..6b849324474e41084114e0c871242c3994d0c122 100644 (file)
@@ -20,7 +20,7 @@
 try:
   from string import Template
 except:
-  from compat import Template,set
+  from module_generator.compat import Template,set
 
 # CORBA idl
 
index 672b33dde2d5475b32b0cc5fb9b36464669d7023..fd01532afab9471127bf48f14e0c057c014579d4 100644 (file)
@@ -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]*'
index 1b3a897af119f2336f4cec3048eddf10a311cce1..2462e07e3a69c08fcea8959a568352050d791d60 100644 (file)
@@ -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"
index 4d09676dcd66bd3cf7b56ec29e925c981e7993fe..75a9f0893f1bdfc42e1b813dfa6389b1a15d117f 100644 (file)
 """
 
 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):
   """
index bed13624686c758a6a26188564d5aa51cdf76acc..1d906e1eec58fea7ec77387f29b0493042bf2cb3 100644 (file)
@@ -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:
index 03dbf455abbe910109cdb77d50889672555446ed..4fcc90d712667147319a6b8a38dc7ad3d4e3155a 100644 (file)
@@ -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]
index d1649380b239350d31c950443bf36f65f728cd55..ce80d856f650b7467dca1a8e566801f824619a7d 100644 (file)
@@ -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 name="%s" path="%s"/>' % (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()
-
index 5b5237c348576058945339073dac3fe8b498cfda..f16ed06e356d3aea41683fe5aef01cb2b4fa0ea4 100644 (file)
@@ -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:
index 1496c8cdaffae35061679b83512bcc1b8c636cdb..f6b2537308f515009aa3ae7dcdfa07aafa17bd94 100644 (file)
@@ -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
index 48b755267536877d337fb9a30052990c098f0d05..a5f5dfcca9a6f1ce0c0b6ab7b4fc25e9351bb8db 100644 (file)
@@ -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
index cc5eff8aa5f1700d85fb6c7f579cd6b8e85cf798..b54881fa0953d954410371ad936d220752f94812 100644 (file)
@@ -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"
index 32020277b1d87be5877c76f15a9f11a753ecffe1..e02711d2657c732f08c41b3f673d1261cdef9883 100644 (file)
 
 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"
index 059dbcec6a1f69260469e7baed4f5b2ee7a38082..59c7b6880a77b49dea8121e002393d6d1b472a65 100644 (file)
 
 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))
index 793377ae61076363050a65dda8475945502b0545..55ef07c1cfa0a0ce0cb67871572d866c4f4086dd 100644 (file)
@@ -20,7 +20,7 @@
 try:
   from string import Template
 except:
-  from compat import Template,set
+  from module_generator.compat import Template,set
 
 application="""
 <application>
index c393c1c5fe863e5d8abe5d6a1ea7e7c65cdb86c4..cc51bd0138498258fbdbe8d743175c90f1f13751 100644 (file)
@@ -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:
index 5703a9088f8426f0972594de3a69b3ab49319391..b060c52d73994f32e276cc74e69d5ae2e061e83f 100644 (file)
 """
 
 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):
   """
index 064b2607d9e537493bc37a1e31662074b1c442fa..bcf190df381a4517b10971017e8364fa9f89597b 100644 (file)
@@ -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
index 7950e3d68c6c6c4d23428a11c70b7fe456f5a35a..4a895f628499e85c5a33890f893a2e76df4aee43 100644 (file)
   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):
 
index 85cf820c07925e6e19581ff21bf9c1eb3fc9f41e..18796669f051f27d8e8adb2c5fa00d743086442f 100644 (file)
@@ -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,
index e8199139dd6bffe8bbc7e4f7e4b48120c9da4929..a5d86a12a79d33b76ca86d64807560ef5848f9b0 100644 (file)
@@ -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
index abb2c5de63cdefffc47865bc9365ebc6cb4263ca..637948427654da6923e7270e45674428c1ea27ea 100644 (file)
@@ -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
index 053e697840cf339efee3a3a48f541efddb17630f..6fda8ede15e67f77e990baf7c8a58e0a0699c112 100755 (executable)
@@ -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