From debcf0cd8eb3cce498c13824ddf689b8a0a8b52d Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Thu, 9 Feb 2017 16:29:12 +0100 Subject: [PATCH] exceptions prints --- generator/DefautASTER.py | 6 +- generator/Formatage.py | 6 +- generator/generator_Creation.py | 134 ------------------ generator/generator_TELEMAC.py | 27 +--- generator/generator_ZCracks.py | 2 +- generator/generator_dico.py | 2 +- generator/generator_map.py | 2 +- generator/generator_modification.py | 1 - generator/generator_python.py | 6 - generator/generator_vers3DSalome.py | 13 +- generator/{ => oldCodes}/OpenturnsBase.py | 0 generator/{ => oldCodes}/OpenturnsSTD.py | 0 generator/{ => oldCodes}/OpenturnsXML.py | 0 generator/{ => oldCodes}/generator_SEP.py | 0 generator/{ => oldCodes}/generator_cuve2dg.py | 0 generator/{ => oldCodes}/generator_homard.py | 0 .../{ => oldCodes}/generator_openturns.py | 0 .../generator_openturns_study.py | 0 .../generator_openturns_wrapper.py | 0 19 files changed, 19 insertions(+), 180 deletions(-) delete mode 100644 generator/generator_Creation.py rename generator/{ => oldCodes}/OpenturnsBase.py (100%) rename generator/{ => oldCodes}/OpenturnsSTD.py (100%) rename generator/{ => oldCodes}/OpenturnsXML.py (100%) rename generator/{ => oldCodes}/generator_SEP.py (100%) rename generator/{ => oldCodes}/generator_cuve2dg.py (100%) rename generator/{ => oldCodes}/generator_homard.py (100%) rename generator/{ => oldCodes}/generator_openturns.py (100%) rename generator/{ => oldCodes}/generator_openturns_study.py (100%) rename generator/{ => oldCodes}/generator_openturns_wrapper.py (100%) diff --git a/generator/DefautASTER.py b/generator/DefautASTER.py index 8828a994..7a120f32 100644 --- a/generator/DefautASTER.py +++ b/generator/DefautASTER.py @@ -39,7 +39,7 @@ TexteSTDFIN += "\nif error_message is not None :\n" TexteSTDFIN += DecalSTD + "texte = \"\\n=================================================\"" TexteSTDFIN += DecalSTD + "texte += \"\\nMessage d'erreur : \" + str(error_message)" TexteSTDFIN += DecalSTD + "texte += \"\\n=================================================\\n\"" -TexteSTDFIN += DecalSTD + "print texte" +TexteSTDFIN += DecalSTD + "print (texte)" TexteSTDFIN += DecalSTD + "\nsys.exit(error_message)\n" # C.2. Definition de composants dans le fichier STD @@ -145,7 +145,7 @@ class MonSTDGenerateur(STDGenerateur) : Algorithm = str (self.DictMCVal["Algorithm"]) texte = "\n\n# Le resultat\n" texte += DecalSTDsaut + NomResu + " = " + NomAlgo + ".getResult()" - texte += DecalSTDsaut + "###" + "print " + NomResu + texte += DecalSTDsaut + "###" + "print ( " + NomResu+")" texte += DecalSTDsaut + "text_resu = \"Resultats\\n=======\\n\"" # Particularites des algorithmes de fiabilite @@ -222,7 +222,7 @@ class MonSTDGenerateur(STDGenerateur) : # Impression - texte += DecalSTDsaut + "print \"\\n\", text_resu, \"\\n\"" + texte += DecalSTDsaut + "print ( \"\\n\", text_resu, \" ) \\n\"" texte += DecalSTDsaut + "file_resu = open(\"" + self.fic_resu_OpenTURNS + "\", \"w\")" texte += DecalSTDsaut + "file_resu.write(text_resu)" texte += DecalSTDsaut + "file_resu.close()" diff --git a/generator/Formatage.py b/generator/Formatage.py index 0f8efaa9..31edf1ab 100644 --- a/generator/Formatage.py +++ b/generator/Formatage.py @@ -126,9 +126,9 @@ class Formatage : try: increment = len(('\n'+self.indent_courant*' ')*ind + element[0]) except: - print tr('ERREUR') - print liste - print element + print (tr('ERREUR')) + print (liste) + print (element) self.texte_etape = self.texte_etape + (u'\n'+self.indent_courant*' ')*ind + element[0] length = len(self.indent) self.indent.insert(length,self.indent[length-1]+len(element[0])) diff --git a/generator/generator_Creation.py b/generator/generator_Creation.py deleted file mode 100644 index 8b427f73..00000000 --- a/generator/generator_Creation.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 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 -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -""" - Ce module contient le plugin generateur de fichier au format - CARMEL3D pour EFICAS. - -""" -import traceback -import types,string,re,os -from Extensions.i18n import tr -from generator_python import PythonGenerator -debut=""" -lqdkqmldk -""" - - -def entryPoint(): - """ - Retourne les informations necessaires pour le chargeur de plugins - - Ces informations sont retournees dans un dictionnaire - """ - return { - # Le nom du plugin - 'name' : 'Creation', - # La factory pour creer une instance du plugin - 'factory' : CreationGenerator, - } - - -class CreationGenerator(PythonGenerator): - """ - - """ - # Les extensions de fichier permis? - - def gener(self,obj,format='brut',config=None): - - self.initDico(obj) - # Cette instruction genère le contenu du fichier de commandes (persistance) - self.text=PythonGenerator.gener(self,obj,format) - if obj.isvalid() : self.genereDescription() - return self.text - - - def genereParam(self): - listeParam=[] - for monParam in self.dictParam.keys(): - if self.dico.has_key(monParam) : continue - listeParam.append(self.dictParam[monParam]) - - if len(listeParam)== 0 : return - try: - jdcDict=self.jdc.jdcDict - except: - raise ValueError,tr("toutes les donnees ne sont pas connues") - for param in listeParam: - obj=None - for etape in self.jdc.jdcDict.etapes: - if str(etape.sdnom) != str(param) : - continue - obj=etape - break - - if obj==None: - raise ValueError,tr("toutes les donnees ne sont pas connues") - return - - texteEtape=self.generETAPE(obj) - - def genereDescription(self) : - ''' - ''' - self.texte=debut - self.genereParam() - - def initDico(self,obj) : - self.dicoCourant={} - self.dico={} - self.dictParam={} - self.listeParam=[] - self.jdc=obj.get_jdc_root() - try : - self.texte_jdc_aux=self.jdc.recorded_units[999] - except : - self.texte_jdc_aux="" - - - def generMCSIMP(self,obj) : - """ - Convertit un objet MCSIMP en texte python - Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable - """ - - #print "MCSIMP", obj.nom, " ", obj.valeur - from cree_map_cata import param_map - if isinstance(obj.valeur,param_map): - self.dicoCourant[obj.nom]=obj.valeur.nom - self.dictParam[obj.valeur.nom]=obj.valeur - else : - self.dicoCourant[obj.nom]=obj.valeur - s=PythonGenerator.generMCSIMP(self,obj) - return s - - def generPROC_ETAPE(self,obj): - self.dicoCourant={} - s=PythonGenerator.generPROC_ETAPE(self,obj) - self.dico[obj.nom]=self.dicoCourant - return s - - def generETAPE(self,obj): - #print "ETAPE", obj.nom, " ",obj.sdnom - self.dicoCourant={} - s=PythonGenerator.generETAPE(self,obj) - self.dico[obj.sdnom]=self.dicoCourant - return s - diff --git a/generator/generator_TELEMAC.py b/generator/generator_TELEMAC.py index 9e01ebf1..570de154 100644 --- a/generator/generator_TELEMAC.py +++ b/generator/generator_TELEMAC.py @@ -138,8 +138,6 @@ class TELEMACGenerator(PythonGenerator): self.texteDico += '/\t\t\t'+obj.nom +'\n' self.texteDico += '/------------------------------------------------------/\n' s=PythonGenerator.generPROC_ETAPE(self,obj) - #print obj - #print obj.nom if obj.nom in TELEMACGenerator.__dict__.keys() : apply(TELEMACGenerator.__dict__[obj.nom],(self,obj)) return s @@ -147,10 +145,6 @@ class TELEMACGenerator(PythonGenerator): def generMCSIMP(self,obj) : """recuperation de l objet MCSIMP""" s=PythonGenerator.generMCSIMP(self,obj) - #if obj.nom == "Title" : - #print s - # print str(obj.valeur) - #print repr(obj.valeur) # Attention pas sur --> ds certains cas non traite par MCFACT ? @@ -172,15 +166,14 @@ class TELEMACGenerator(PythonGenerator): if not( type(obj.valeur) in (types.TupleType,types.ListType) ): if obj.nom in DicoEnumCasEnInverse.keys(): try : sTelemac=str(DicoEnumCasEnInverse[obj.nom][obj.valeur]) - except : print "generMCSIMP Pb valeur avec ", obj.nom, obj.valeur + except : print ("generMCSIMP Pb valeur avec ", obj.nom, obj.valeur) if type(obj.valeur) in (types.TupleType,types.ListType) : - #print "je passe pour", obj.nom if obj.nom in DicoEnumCasEnInverse.keys(): #sT = "'" sT='' for v in obj.valeur: try : sT +=str(DicoEnumCasEnInverse[obj.nom][v]) +";" - except : print "generMCSIMP Pb Tuple avec ", obj.nom, v, obj.valeur + except : print ("generMCSIMP Pb Tuple avec ", obj.nom, v, obj.valeur) #sTelemac=sT[0:-1]+"'" sTelemac=sT[0:-1] else : @@ -207,7 +200,6 @@ class TELEMACGenerator(PythonGenerator): if obj.nom not in self.dicoCataToCas : if obj.nom == 'Consigne' : return "" - print obj.nom , ' non traite' return s nom=self.dicoCataToCas[obj.nom] @@ -217,11 +209,6 @@ class TELEMACGenerator(PythonGenerator): ligne=nom+ " : " + s3 + "\n" if len(ligne) > 72 : ligne=self.redecoupeLigne(nom,s3) self.texteDico+=ligne - #print "_______________________" - #print s - #print ligne - #print "_______________________" - return s def generMCFACT(self,obj): """ @@ -256,7 +243,6 @@ class TELEMACGenerator(PythonGenerator): self.VE=True self.textVE += str(valeur) +"; " else : self.textVE += "0.; " - print self.textPE, self.textFE,self.textVE def BOUNDARY_CONDITIONS(self,obj): # sans '; ' @@ -269,8 +255,8 @@ class TELEMACGenerator(PythonGenerator): def NAME_OF_TRACER(self,obj): - print dir(obj) - print obj.get_genealogie_precise() + print (dir(obj) ) + print (obj.get_genealogie_precise()) def Validation(self,obj): self.texteDico += "VALIDATION : True \n" @@ -279,14 +265,12 @@ class TELEMACGenerator(PythonGenerator): an=obj.get_child('Year').valeur mois=obj.get_child('Month').valeur jour=obj.get_child('Day').valeur - #print an, mois, jour self.texteDico += "ORIGINAL DATE OF TIME :"+ str(an)+ " ,"+str(mois)+ "," +str(jour)+ "\n" def Original_Hour_Of_Time (self,obj): hh=obj.get_child('Hour').valeur mm=obj.get_child('Minute').valeur ss=obj.get_child('Second').valeur - #print hh, mm, ss self.texteDico += "ORIGINAL HOUR OF TIME :"+str(hh)+" ,"+str(mm)+ ","+str(ss)+"\n" def Type_Of_Advection(self,obj): @@ -297,12 +281,9 @@ class TELEMACGenerator(PythonGenerator): self.chercheChildren(obj) dicoSuf={ 'U_And_V' : 0, 'H' : 1, 'K_And_Epsilon' : 2, 'Tracers' : 3} for c in self.listeMCAdvection: - #print c.nom if c.nom[0:18] == 'Type_Of_Advection_' and c.valeur!=None: suf=c.nom[18:] index=dicoSuf[suf] - #print c.valeur - #print DicoEnumCasEnInverse['Type_Of_Advection'] listeAdvection[index]=DicoEnumCasEnInverse['Type_Of_Advection'][c.valeur] if c.nom[0:13] == 'Supg_Option_' and c.valeur!=None: suf=c.nom[13:] diff --git a/generator/generator_ZCracks.py b/generator/generator_ZCracks.py index 17ce5e0c..eb3324bf 100644 --- a/generator/generator_ZCracks.py +++ b/generator/generator_ZCracks.py @@ -80,7 +80,7 @@ class ZCrackGenerator(PythonGenerator): def writeDefault(self,fn) : fileZcrack = fn[:fn.rfind(".")] + '.z7p' f = open( str(fileZcrack), 'wb') - print self.textePourRun + print (self.textePourRun) self.ajoutRun() self.textePourRunAvecDouble=self.textePourRun.replace("'",'"') diff --git a/generator/generator_dico.py b/generator/generator_dico.py index a3f752e9..bb50e370 100644 --- a/generator/generator_dico.py +++ b/generator/generator_dico.py @@ -75,7 +75,7 @@ class DicoGenerator(PythonGenerator): fileDico = fn[:fn.rfind(".")] + '.py' f = open( str(fileDico), 'wb') f.write( self.texteDico ) - print self.texteDico + print (self.texteDico) f.close() #---------------------------------------------------------------------------------------- diff --git a/generator/generator_map.py b/generator/generator_map.py index b0637c9e..e3f3a91e 100644 --- a/generator/generator_map.py +++ b/generator/generator_map.py @@ -98,7 +98,7 @@ class MapGenerator(PythonGenerator): def generRUN(self,obj,schema): if not(obj.isvalid()) : - print "TODO TODO TODO" + print ("TODO TODO TODO") self.texteEXE="" self.schema=schema textComm=self.gener(obj) diff --git a/generator/generator_modification.py b/generator/generator_modification.py index fa5a130a..ac773472 100644 --- a/generator/generator_modification.py +++ b/generator/generator_modification.py @@ -29,7 +29,6 @@ class ModificationGenerator: texteModification="" for t in obj.editor.dicoNouveauxMC.keys() : # 'ajoutDefinitionMC',etape,listeAvant,nomDuMC,typ,args - print t fonction,Etape,Genea,nomSIMP,typeSIMP,arguments = obj.editor.dicoNouveauxMC[t] texteModification += "MODIFICATION_CATALOGUE(Fonction = '" + str(fonction)+ "',\n" texteModification += " Etape = '" + str(Etape) + "',\n" diff --git a/generator/generator_python.py b/generator/generator_python.py index 30b538af..e49ca579 100644 --- a/generator/generator_python.py +++ b/generator/generator_python.py @@ -96,7 +96,6 @@ class PythonGenerator: """ self.appli=obj.get_jdc_root().appli #self.appli=obj.appli - #print format liste= self.generator(obj) if format == 'brut': self.text=liste @@ -517,7 +516,6 @@ class PythonGenerator: # mais seulement le nom dans le cas d'un parametre # s = valeur.nom # else: - # print valeur # s = self.generator(valeur) else : @@ -551,7 +549,6 @@ class PythonGenerator: obj.valeurFormatee.append(val) else : obj.valeurFormatee.append(self.format_item(val,obj.etape,obj)) - #print obj.valeurFormatee if len(obj.valeur) >= 1: s = '(' + s + '),' if obj.valeur==[] or obj.valeur==() : s="()," @@ -560,13 +557,11 @@ class PythonGenerator: else : obj.valeurFormatee=obj.valeur s=self.format_item(obj.valeur,obj.etape,obj) + ',' - #print s return s def formatColonnes(self,nbrColonnes,listeValeurs,obj): #try : - #print listeValeurs if 1 == 1 : indice=0 textformat="(" @@ -589,5 +584,4 @@ class PythonGenerator: #except : else : textformat=str(obj.valeur) - #print textformat return textformat diff --git a/generator/generator_vers3DSalome.py b/generator/generator_vers3DSalome.py index f1be205b..09582f21 100644 --- a/generator/generator_vers3DSalome.py +++ b/generator/generator_vers3DSalome.py @@ -38,14 +38,14 @@ from generator_python import PythonGenerator def entryPoint(): """ - Retourne les informations nécessaires pour le chargeur de plugins + Retourne les informations necessaires pour le chargeur de plugins - Ces informations sont retournées dans un dictionnaire + Ces informations sont retournees dans un dictionnaire """ return { # Le nom du plugin 'name' : 'vers3DSalome', - # La factory pour créer une instance du plugin + # La factory pour creer une instance du plugin 'factory' : vers3DSalomeGenerator, } @@ -94,7 +94,6 @@ class vers3DSalomeGenerator(PythonGenerator): self.node=node self.list_commandes=[]; self.generator(self.node.object) - #print self.list_commandes return self.list_commandes def generator(self,obj): @@ -150,7 +149,7 @@ class vers3DSalomeGenerator(PythonGenerator): def generMCFACT(self,obj): """ - Convertit un objet MCFACT en une liste de chaines de caractères à la + Convertit un objet MCFACT en une liste de chaines de caracteres a la syntaxe python """ self.init_ligne() @@ -205,12 +204,12 @@ class vers3DSalomeGenerator(PythonGenerator): val = val[0] if isinstance (val, Extensions.parametre.PARAMETRE): val=val.valeur - print val.__class__ + print ( val.__class) context={} if type(val) == type("aaa") : for p in self.jdc.params: context[p.nom]=eval(p.val,self.jdc.const_context, context) - print context[p.nom] + print (context[p.nom]) res=eval(val,self.jdc.const_context, context) val=res self.dict_attributs[clef]=val diff --git a/generator/OpenturnsBase.py b/generator/oldCodes/OpenturnsBase.py similarity index 100% rename from generator/OpenturnsBase.py rename to generator/oldCodes/OpenturnsBase.py diff --git a/generator/OpenturnsSTD.py b/generator/oldCodes/OpenturnsSTD.py similarity index 100% rename from generator/OpenturnsSTD.py rename to generator/oldCodes/OpenturnsSTD.py diff --git a/generator/OpenturnsXML.py b/generator/oldCodes/OpenturnsXML.py similarity index 100% rename from generator/OpenturnsXML.py rename to generator/oldCodes/OpenturnsXML.py diff --git a/generator/generator_SEP.py b/generator/oldCodes/generator_SEP.py similarity index 100% rename from generator/generator_SEP.py rename to generator/oldCodes/generator_SEP.py diff --git a/generator/generator_cuve2dg.py b/generator/oldCodes/generator_cuve2dg.py similarity index 100% rename from generator/generator_cuve2dg.py rename to generator/oldCodes/generator_cuve2dg.py diff --git a/generator/generator_homard.py b/generator/oldCodes/generator_homard.py similarity index 100% rename from generator/generator_homard.py rename to generator/oldCodes/generator_homard.py diff --git a/generator/generator_openturns.py b/generator/oldCodes/generator_openturns.py similarity index 100% rename from generator/generator_openturns.py rename to generator/oldCodes/generator_openturns.py diff --git a/generator/generator_openturns_study.py b/generator/oldCodes/generator_openturns_study.py similarity index 100% rename from generator/generator_openturns_study.py rename to generator/oldCodes/generator_openturns_study.py diff --git a/generator/generator_openturns_wrapper.py b/generator/oldCodes/generator_openturns_wrapper.py similarity index 100% rename from generator/generator_openturns_wrapper.py rename to generator/oldCodes/generator_openturns_wrapper.py -- 2.39.2