From: caremoli Date: Thu, 25 Mar 2010 19:02:46 +0000 (+0000) Subject: CCAR: adapte la generation du composant aster aux versions d'aster superieures X-Git-Tag: V5_1_4a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb7dc9311ddb27f9d43103e4c728e6940153a05a;p=tools%2Fyacsgen.git CCAR: adapte la generation du composant aster aux versions d'aster superieures a 10.1.1. Il n'est plus necessaire de patcher E_SUPERV.py mais on le copie toujours dans le module genere. --- diff --git a/module_generator/astcompo.py b/module_generator/astcompo.py index f4f1efb..7cbe337 100644 --- a/module_generator/astcompo.py +++ b/module_generator/astcompo.py @@ -10,6 +10,7 @@ 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 @@ -62,6 +63,16 @@ class ASTERComponent(Component): filename = "%s.py" % self.name #on suppose que les composants ASTER sont homogenes (utilisent meme install) gen.aster = self.aster_dir + + #get ASTER version + f = os.path.join(self.aster_dir, "bibpyt", 'Accas', 'properties.py') + self.version=(0,0,0) + if os.path.isfile(f): + mydict = {} + execfile(f, mydict) + v,r,p = mydict['version'].split('.') + self.version=(int(v),int(r),int(p)) + if self.kind == "lib": return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), filename:self.makeaster(gen)} @@ -99,15 +110,20 @@ class ASTERComponent(Component): def makeexepath(self, gen): """standalone component: generate files for calculation code""" - #patch to E_SUPERV.py + + #copy and patch E_SUPERV.py fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) esuperv = fil.read() fil.close() - esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) - esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) - esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) - esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) - esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + + if self.version < (10,1,2): + #patch to E_SUPERV.py + esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) + esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) + esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) + esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) + esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + #use a specific main program (modification of config.txt file) fil = open(os.path.join(self.aster_dir, "config.txt")) config = fil.read() @@ -128,15 +144,20 @@ class ASTERComponent(Component): def makecexepath(self, gen): """specific container: generate files""" - #patch to E_SUPERV.py + + #copy and patch E_SUPERV.py fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) esuperv = fil.read() fil.close() - esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) - esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) - esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) - esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) - esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + + if self.version < (10,1,2): + #patch to E_SUPERV.py + esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) + esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) + esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) + esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) + esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + #use a specific main program fil = open(os.path.join(self.aster_dir, "config.txt")) @@ -207,6 +228,7 @@ class ASTERComponent(Component): instream=instream, outstream=outstream) services.append(service) inits.append(init) + return asterEXECompo.substitute(component=self.name, module=gen.module.name, servicesdef="\n".join(defs), servicesimpl="\n".join(services), @@ -266,12 +288,14 @@ class ASTERComponent(Component): outstream=outstream) services.append(service) inits.append(init) + return asterCEXECompo.substitute(component=self.name, module=gen.module.name, servicesdef="\n".join(defs), servicesimpl="\n".join(services), initservice='\n'.join(inits), aster_dir=self.aster_dir) + def getImpl(self): if self.kind == "cexe": return "CEXE", self.name+".exe"