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)
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)
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
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
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()
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()
#
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
import os
from module_generator import *
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
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()
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")
#
f=myCoco1.getOutputField("SourceField")
myCoco2.printField(f)
#
-print "##################################"
-print "Fin test hxx2salome/ICOCO/A2"
+print("##################################")
+print("Fin test hxx2salome/ICOCO/A2")
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()
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()
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()
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import *
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import *
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):
# 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)
#
def f():
- print "coucou"
+ print("coucou")
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()
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()
#start salome and connect to it
try:
salome_module.main(["start", "-t"])
- except SystemExit, e:
+ except SystemExit as e:
pass
import runSession
runSession.configureSession()
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()
def tearDown(self):
try:
salome_module.main(["killall"])
- except SystemExit, e:
+ except SystemExit as e:
pass
if __name__ == '__main__':
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
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
"""
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):
"""
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
asterCompo="""
import sys,traceback,os
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
# CORBA idl
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 :
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]*'
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
cxxCompo="""
#include "${component}.hxx"
"""
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):
"""
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:
# 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]
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"""
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):
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
"""
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)
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"
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)
# 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,
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,
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
# For PaCO++
def makexml(self):
- from pacocompo import PACOComponent
+ from .pacocompo import PACOComponent
interfaces = []
for compo in self.module.components:
if isinstance(compo, PACOComponent):
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')
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
host = socket.gethostname().split('.')[0]
fil.write(command % host)
fil.close()
-
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:
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
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
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"
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
# ------------------------------------------------------------------------------
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
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]
# - 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
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 \
# 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 += \
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),
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,
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,
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"
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 ):
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
# ...
# 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"
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]
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="""
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
# 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
# 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
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
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,
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 + ","
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))
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
application="""
<application>
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:
"""
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):
"""
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
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):
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
"""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')
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,
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
pyCompo="""
import sys,traceback,os
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):
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
# 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,
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