"""Ce module contient le plugin generateur de fichier au format Code_Carmel3D pour EFICAS.
"""
+from __future__ import absolute_import
+try :
+ from builtins import str
+except : pass
+
import traceback
-import types,string,re,os
+import types,re,os
from Extensions.i18n import tr
-from generator_python import PythonGenerator
+from .generator_python import PythonGenerator
def entryPoint():
"""
extensions=('.comm',)
#----------------------------------------------------------------------------------------
- def gener(self,obj,format='brut',config=None):
+ def gener(self,obj,format='brut',config=None, appli=None):
self.initDico()
# Cette instruction genere le contenu du fichier de commandes (persistance)
self.text=PythonGenerator.gener(self,obj,format)
+ #print (self.text)
return self.text
+
#----------------------------------------------------------------------------------------
# initialisations
#----------------------------------------------------------------------------------------
def initDico(self) :
self.Dico={}
+ self.DicoDejaLa={}
+ self.Entete = ''
#----------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------
def writeDefault(self,fn) :
- print "je passe par writeDefault"
fileDico = fn[:fn.rfind(".")] + '.py'
f = open( str(fileDico), 'wb')
- f.write( str(self.Dico) )
+
+ f.write( self.Entete + "Dico =" + str(self.Dico) )
f.close()
#----------------------------------------------------------------------------------------
def generMCSIMP(self,obj) :
"""recuperation de l objet MCSIMP"""
+
s=PythonGenerator.generMCSIMP(self,obj)
- liste=obj.get_genealogie()
- dicoCourant=self.Dico
- for i in liste [0:-1]:
- if not(dicoCourant.has_key(i)) : dicoCourant[i]={}
- dicoCourant=dicoCourant[i]
- dicoCourant[liste[-1]]=obj.valeur
+ if obj.isInformation() : return s
+ if not obj.isvalid() : return s
+
+ liste=obj.get_genealogie_precise()
+
+ if obj.etape.nom=='MODIFICATION_CATALOGUE' : return s
+ nom = obj.etape.nom
+
+ if hasattr(obj.etape,'sdnom') and obj.etape.sdnom != None and obj.etape.sdnom != "" :
+ nom = nom+ obj.etape.sdnom
+
+ if not(nom in self.Dico) : dicoCourant={}
+ else : dicoCourant=self.Dico [nom]
+
+ nomFeuille=liste[-1]
+ if nomFeuille in dicoCourant or nomFeuille in self.DicoDejaLa:
+ if nomFeuille in self.DicoDejaLa:
+ nomTravail= nomFeuille +'_'+str(self.DicoDejaLa[nomFeuille])
+ self.DicoDejaLa[nomFeuille]=self.DicoDejaLa[nomFeuille]+1
+ nomFeuille=nomTravail
+ else :
+ self.DicoDejaLa[nomFeuille]=3
+ nom1=nomFeuille +'_1'
+ dicoCourant[nom1]= dicoCourant[nomFeuille]
+ del dicoCourant[nomFeuille]
+ nomFeuille=nomFeuille +'_2'
+
+
+ if hasattr(obj.valeur,'nom'): dicoCourant[nomFeuille]=obj.valeur.nom
+ else :
+ if type(obj.valeur) in (list,tuple):
+ try :
+#PNPNPN a remplacer par plus propre
+ if obj.definition.validators.typeDesTuples[0] !='R' :
+ val=[]
+ elt=[]
+ for tupleElt in obj.valeur :
+ elt=(str(tupleElt[0]),tupleElt[1])
+ val.append(elt)
+ dicoCourant[nomFeuille]=val
+ else :
+ dicoCourant[nomFeuille]=obj.valeur
+ except :
+ dicoCourant[nomFeuille]=obj.valeurFormatee
+ #else :dicoCourant[nomFeuille]=obj.valeurFormatee
+ else :
+ dicoCourant[nomFeuille]=obj.valeurFormatee
+ #print nomFeuille, obj.valeurFormatee
+ self.Dico[nom]=dicoCourant
+
return s