Salome HOME
Copyright update 2021
[tools/yacsgen.git] / module_generator / aster_tmpl.py
index 0c6fa1624e3b4e22331e94836f3fbc94bc1e6223..a5c55dadc586310ed50345de9d80f13f57916330 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2014  EDF R&D
+# Copyright (C) 2009-2021  EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -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
@@ -89,7 +89,6 @@ asterCEXECompo="""
 # Interet: introduire DEBUT() dans ce prefixe pour ne plus avoir a s'en preoccuper (ex: boucle for each)
 import sys,traceback,os
 import string
-import cPickle
 import ${module}_ORB__POA
 import calcium
 import dsccalcium
@@ -136,7 +135,7 @@ ${initservice}
     return jdc
 
   def insertPrePost(self,jdc,prepost):
-    if prepost <> "":
+    if prepost != "":
       exec(prepost)
       try:
         jdc = os.linesep + pre + os.linesep + jdc + os.linesep + post + os.linesep
@@ -149,7 +148,7 @@ ${initservice}
       self.jdc.g_context.update(args)
       CONTEXT.set_current_step(self.jdc)
       linecache.cache['<string>']=0,None,string.split(text,'\\n'),'<string>'
-      exec text in self.jdc.const_context,self.jdc.g_context
+      exec(text in self.jdc.const_context,self.jdc.g_context)
       CONTEXT.unset_current_step()
     except EOFError:
       CONTEXT.unset_current_step()
@@ -191,9 +190,9 @@ asterService="""
     if not j.cr.estvide():
        msg="ERREUR DE COMPILATION DANS ACCAS - INTERRUPTION"
        self.MESSAGE(msg)
-       print ">> JDC.py : DEBUT RAPPORT"
-       print j.cr
-       print ">> JDC.py : FIN RAPPORT"
+       print (">> JDC.py : DEBUT RAPPORT")
+       print (j.cr)
+       print (">> JDC.py : FIN RAPPORT")
        j.supprime()
        sys.stdout.flush()
        raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0))
@@ -223,14 +222,14 @@ asterService="""
        msg="ERREUR A L'INTERPRETATION DANS ACCAS - INTERRUPTION"
        self.MESSAGE(msg)
        ier=1
-       print ">> JDC.py : DEBUT RAPPORT"
-       print j.cr
-       print ">> JDC.py : FIN RAPPORT"
+       print (">> JDC.py : DEBUT RAPPORT")
+       print (j.cr)
+       print (">> JDC.py : FIN RAPPORT")
        sys.stdout.flush()
        raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr), "${component}.py",0))
 
     if j.par_lot == 'NON':
-       print "FIN EXECUTION"
+       print ("FIN EXECUTION")
        #err=calcium.cp_fin(self.proxy,calcium.CP_ARRET)
        #retour sans erreur (il faut pousser les variables de sortie)
        sys.stdout.flush()
@@ -242,9 +241,9 @@ asterService="""
     if not cr.estvide():
        msg="ERREUR A LA VERIFICATION SYNTAXIQUE - INTERRUPTION"
        self.MESSAGE(msg)
-       print ">> JDC.py : DEBUT RAPPORT"
-       print cr
-       print ">> JDC.py : FIN RAPPORT"
+       print( ">> JDC.py : DEBUT RAPPORT")
+       print( cr)
+       print( ">> JDC.py : FIN RAPPORT")
        sys.stdout.flush()
        raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(cr),"${component}.py",0))
 
@@ -256,9 +255,9 @@ asterService="""
           msg="ERREUR A L'EXECUTION - INTERRUPTION"
           self.MESSAGE(msg)
           ier=1
-          print ">> JDC.py : DEBUT RAPPORT"
-          print j.cr
-          print ">> JDC.py : FIN RAPPORT"
+          print( ">> JDC.py : DEBUT RAPPORT")
+          print( j.cr)
+          print( ">> JDC.py : FIN RAPPORT")
           sys.stdout.flush()
           raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0))
        else:
@@ -281,7 +280,7 @@ asterCEXEService="""
     self.beginService("${component}.${service}")
     try:
       args=${dvars}
-      if not args.has_key("jdc"):
+      if "jdc" not in args:
         fcomm=open("jdc",'r')
         jdc=fcomm.read()
         fcomm.close()
@@ -380,15 +379,15 @@ from SALOME_ContainerPy import SALOME_ContainerPy_i
 
 if __name__ == '__main__':
 
-  print sys.argv
+  print( sys.argv)
   orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
   poa = orb.resolve_initial_references("RootPOA")
-  print "ORB and POA initialized"
+  print( "ORB and POA initialized")
   containerName=os.getenv("SALOME_CONTAINERNAME")
   cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
-  print "SALOME_ContainerPy_i instance created ",cpy_i
+  print( "SALOME_ContainerPy_i instance created ",cpy_i)
   cpy_o = cpy_i._this()
-  print "SALOME_ContainerPy_i instance activated ",cpy_o
+  print( "SALOME_ContainerPy_i instance activated ",cpy_o)
   sys.stdout.flush()
   sys.stderr.flush()
 
@@ -398,7 +397,7 @@ if __name__ == '__main__':
 
   #Block for ever
   orb.run()
-  print "fin container aster"
+  print( "fin container aster")
   sys.stdout.flush()
   sys.stderr.flush()
 """
@@ -409,10 +408,10 @@ from ${component}_module import ${component}
 
 if __name__ == '__main__':
 
-  print sys.argv
+  print( sys.argv)
   orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
   poa = orb.resolve_initial_references("RootPOA")
-  print "ORB and POA initialized",orb,poa
+  print( "ORB and POA initialized",orb,poa)
   sys.stdout.flush()
   sys.stderr.flush()
 
@@ -423,7 +422,7 @@ if __name__ == '__main__':
   compo=${component}(orb,poa,container,containerName, instanceName, "${component}")
   comp_o = compo._this()
   comp_iors = orb.object_to_string(comp_o)
-  print "ior aster",comp_iors
+  print( "ior aster",comp_iors)
 
   sys.stdout.flush()
   sys.stderr.flush()
@@ -433,7 +432,7 @@ if __name__ == '__main__':
   poaManager.activate()
 
   orb.run()
-  print "fin du composant aster standalone"
+  print( "fin du composant aster standalone")
 
 """
 component=Template(component)