Salome HOME
CCAR: merge de la version de developpement V1_12a2 dans la branche principale
[tools/eficas.git] / generator / generator_homard.py
index b4a4f877dfaadc67b795d41d150c351f36f97ee9..e1bf23391f9dca9ba756e39abeef5f49c4b69f8c 100644 (file)
@@ -69,31 +69,29 @@ class HomardGenerator(PythonGenerator):
       # Le texte au format homard est stocké dans l'attribut text
       self.dico_mot_clef={}
       self.assoc={}
-      self.lmots_clef_calcules = ('SuivFron','TypeBila','ModeHOMA','CCAssoci', 'CCNoChaI','HOMaiN__','HOMaiNP1')
-      self.lmots_genea = ('NOM_MED_MAILLAGE_N','NOM_MED_MAILLAGE_NP1')
-#,'COMPOSANTE','NUME_ORDRE','INST','PRECISION','CRITERE')
       self.init_assoc()
       self.text=''
       self.textehomard=[]
 
    def init_assoc(self):
+      self.lmots_clef_calcules = ('SuivFron','TypeBila','ModeHOMA','CCAssoci', 'CCNoChaI','HOMaiN__','HOMaiNP1','CCNumOrI', 'CCNumPTI')
       self.lmot_clef  = ('CCMaiN__', 'CCNoMN__', 'CCIndica', 'CCSolN__', 'CCFronti', 'CCNoMFro', 'CCMaiNP1', 
                          'CCNoMNP1', 'CCSolNP1', 'TypeRaff', 'TypeDera', 'NiveauMa', 'SeuilHau', 'SeuilHRe', 
-                        'SeuilHPE', 'NiveauMi', 'SeuilBas', 'SeuilBRe', 'SeuilBPE', 'ListeStd', 'NumeIter', 
-                        'Langue  ', 'CCGroFro', 'CCNoChaI', 'CCNumOrI', 'CCNumPTI', 'SuivFron', 'TypeBila', 
-                        'ModeHOMA', 'HOMaiN__', 'HOMaiNP1')
+                         'SeuilHPE', 'NiveauMi', 'SeuilBas', 'SeuilBRe', 'SeuilBPE', 'ListeStd', 'NumeIter', 
+                         'Langue  ', 'CCGroFro', 'CCNoChaI', 'CCNumOrI', 'CCNumPTI', 'SuivFron', 'TypeBila', 
+                         'ModeHOMA', 'HOMaiN__', 'HOMaiNP1','CCCoChaI')
 
 # Bizarre demander a Gerald : 
-#              CVSolNP1
-      self.assoc['CCMaiN__']='FICHIERS:NOM_MED_MAILLAGE_N'
-      self.assoc['CCNoMN__']='TRAITEMENT:NOM_MED_MAILLAGE_N'
-      self.assoc['CCIndica']='FICHIERS:NOM_MED_MAILLAGE_N'
-      self.assoc['CCSolN__']='FICHIERS:NOM_MED_MAILLAGE_N'
+#                CVSolNP1
+      self.assoc['CCMaiN__']='FICHIER_MED_MAILLAGE_N'
+      self.assoc['CCNoMN__']='NOM_MED_MAILLAGE_N'
+      self.assoc['CCIndica']='FICHIER_MED_MAILLAGE_N'
+      self.assoc['CCSolN__']='FICHIER_MED_MAILLAGE_N'
       self.assoc['CCFronti']='FIC_FRON'
       self.assoc['CCNoMFro']='NOM_MED_MAILLAGE_FRONTIERE'
-      self.assoc['CCMaiNP1']='FICHIERS:NOM_MED_MAILLAGE_NP1'
-      self.assoc['CCNoMNP1']='TRAITEMENT:NOM_MED_MAILLAGE_NP1'
-      self.assoc['CCSolNP1']='FICHIERS:NOM_MED_MAILLAGE_NP1'
+      self.assoc['CCMaiNP1']='FICHIER_MED_MAILLAGE_NP1'
+      self.assoc['CCNoMNP1']='NOM_MED_MAILLAGE_NP1'
+      self.assoc['CCSolNP1']='FICHIER_MED_MAILLAGE_NP1'
       self.assoc['TypeRaff']='RAFFINEMENT'
       self.assoc['TypeDera']='DERAFFINEMENT'
       self.assoc['NiveauMa']='NIVE_MAX'
@@ -104,14 +102,21 @@ class HomardGenerator(PythonGenerator):
       self.assoc['SeuilBas']='CRIT_DERA_ABS'
       self.assoc['SeuilBRe']='CRIT_DERA_REL'
       self.assoc['SeuilBPE']='CRIT_DERA_PE'
-      self.assoc['ListeStd']='INFORMATION'
+      self.assoc['ListeStd']='MESSAGES'
       self.assoc['NumeIter']='NITER'
       self.assoc['Langue  ']='LANGUE'
       self.assoc['CCGroFro']='GROUP_MA'
 #     self.assoc['CCNoChaI']='NOM_MED' (on doit aussi ajouter 'COMPOSANTE')
       self.assoc['CCNumOrI']='NUME_ORDRE'
-      self.assoc['CCNumPTI']='NUME_ORDRE'
-
+      self.assoc['CCNumPTI']='NUME_PAS_TEMPS'
+      self.assoc['CCCoChaI']='COMPOSANTE'
+     
+      self.dico_mot_depend={}
+     
+      # Attention a la synthaxe
+      self.dico_mot_depend['CCIndica'] ='self.dico_mot_clef["RAFFINEMENT"] == "LIBRE" or self.dico_mot_clef["DERAFFINEMENT"] == "LIBRE"'
+      self.dico_mot_depend['CCSolN__'] ='self.dico_mot_clef.has_key("NITER")'
+      self.dico_mot_depend['CCSolNP1'] ='self.dico_mot_clef.has_key("NITER")'
 
    def gener(self,obj,format='brut'):
       self.text=PythonGenerator.gener(self,obj,format)
@@ -124,35 +129,53 @@ class HomardGenerator(PythonGenerator):
           syntaxe homard
       """
       s=PythonGenerator.generMCSIMP(self,obj)
-      if obj.nom in self.lmots_genea:
-        genea = obj.get_genealogie()
-         clef=genea[1]+":"+genea[-1]
-      else :
-        clef=obj.nom
+      clef=obj.nom
       self.dico_mot_clef[clef]=obj.val
       return s
 
+   def cherche_dependance(self,mot):
+       b_eval = 0
+       a_eval=self.dico_mot_depend[mot]
+       try :
+          b_eval=eval(self.dico_mot_depend[mot])
+       except :
+          for l in a_eval.split(" or "):
+              try:
+                 b_eval=eval(l)
+                 if not (b_eval == 0 ):
+                     break
+              except :
+                 pass
+       return b_eval
+
+
    def genereConfiguration(self):
       ligbla=31*' '
       self.textehomard=[]
       for mot in self.lmot_clef:
+
+#          on verifie d'abord que le mot clef doit bien être calculé
+          if self.dico_mot_depend.has_key(mot) :
+             if self.cherche_dependance(mot) == 0 :
+                      continue
+
           if mot not in self.lmots_clef_calcules :
-            clef_eficas=self.assoc[mot]
+             clef_eficas=self.assoc[mot]
              if self.dico_mot_clef.has_key(clef_eficas):
-               val=self.dico_mot_clef[clef_eficas]
+                val=self.dico_mot_clef[clef_eficas]
                 if val != None:
-                  try :
-                   ligne=mot+' '+val
-                  except:
-                   ligne=mot+' '+repr(val)
-                  ligne.rjust(32)
+                   try :
+                    ligne=mot+' '+val
+                   except:
+                    ligne=mot+' '+repr(val)
+                   ligne.rjust(32)
                    self.textehomard.append(ligne)
           else:
              val=apply(HomardGenerator.__dict__[mot],(self,))
              if val != None:
                 mot.rjust(8)
-               ligne=mot+' '+val
-               ligne.rjust(32)
+                ligne=mot+' '+val
+                ligne.rjust(32)
                 self.textehomard.append(ligne)
 
    def get_homard(self):
@@ -160,9 +183,9 @@ class HomardGenerator(PythonGenerator):
 
    def SuivFron(self):
         val="non"
-       if self.dico_mot_clef.has_key('NOM_MED_MAILLAGE_FRONTIERE'):
-          if self.dico_mot_clef['NOM_MED_MAILLAGE_FRONTIERE'] != None:
-               val="oui"
+        if self.dico_mot_clef.has_key('NOM_MED_MAILLAGE_FRONTIERE'):
+           if self.dico_mot_clef['NOM_MED_MAILLAGE_FRONTIERE'] != None:
+                val="oui"
         return val
 
    def TypeBila(self):
@@ -170,48 +193,61 @@ class HomardGenerator(PythonGenerator):
         retour=None
         dict_val={'NOMBRE':7,'INTERPENETRATION':3,'QUALITE':5,'CONNEXITE':11,'TAILLE':13}
         for mot in ('NOMBRE','QUALITE','INTERPENETRATION','CONNEXITE','TAILLE'):
-           if self.dico_mot_clef.has_key(mot):
-              if (self.dico_mot_clef[mot] == "OUI"):
-                 inttypeBilan=inttypeBilan*dict_val[mot]
+            if self.dico_mot_clef.has_key(mot):
+               if (self.dico_mot_clef[mot] == "OUI"):
+                  inttypeBilan=inttypeBilan*dict_val[mot]
                   retour = repr(inttypeBilan)
-       return retour
+        return retour
 
 
    def ModeHOMA(self):
         intModeHOMA=1
-       if self.dico_mot_clef.has_key('INFORMATION'):
-          if self.dico_mot_clef['INFORMATION'] == "OUI":
-             intModeHOMA=2
+        if self.dico_mot_clef.has_key('INFORMATION'):
+           if self.dico_mot_clef['INFORMATION'] == "OUI":
+              intModeHOMA=2
         return repr(intModeHOMA)
-          
+           
    def CCAssoci(self):
         return 'MED' 
 
    def CCNoChaI(self):
-       if not (self.dico_mot_clef.has_key('NOM_MED')):
-          return None
-       if (self.dico_mot_clef['NOM_MED']== None):
-          return None
-       if not (self.dico_mot_clef.has_key('COMPOSANTE')):
-          return None
+        if not (self.dico_mot_clef.has_key('NOM_MED')):
+           return None
+        if (self.dico_mot_clef['NOM_MED']== None):
+           return None
+        if not (self.dico_mot_clef.has_key('COMPOSANTE')):
+           return None
         if (self.dico_mot_clef['COMPOSANTE']== None):
            return None
-        chaine=self.dico_mot_clef['NOM_MED']+' '+self.dico_mot_clef['COMPOSANTE']
+        chaine=self.dico_mot_clef['COMPOSANTE']+' '+self.dico_mot_clef['NOM_MED']
         return chaine
 
    def HOMaiN__(self):
        chaine=None
        if self.dico_mot_clef.has_key('NITER'):
-         if self.dico_mot_clef['NITER'] != None :
+          if self.dico_mot_clef['NITER'] != None :
              num="M"+repr(self.dico_mot_clef['NITER'])
-            chaine=num+" "+num+".hom"
+             chaine=num+" "+num+".hom"
        return chaine
 
    def HOMaiNP1(self):
        chaine=None
        if self.dico_mot_clef.has_key('NITER'):
-         if self.dico_mot_clef['NITER'] != None :
+          if self.dico_mot_clef['NITER'] != None :
              num="M"+repr(self.dico_mot_clef['NITER']+1)
-            chaine=num+" "+num+".hom"
+             chaine=num+" "+num+".hom"
        return chaine
 
+   def CCNumOrI(self):
+       chaine=repr(1)
+       if self.dico_mot_clef.has_key('NUME_ORDRE'):
+          if self.dico_mot_clef['NUME_ORDRE'] != None :
+             chaine=repr(self.dico_mot_clef['NUME_ORDRE'])
+       return chaine
+
+   def CCNumPTI(self):
+       chaine=repr(1)
+       if self.dico_mot_clef.has_key('NUME_PAS_TEMPS'):
+          if self.dico_mot_clef['NUME_PAS_TEMPS'] != None :
+             chaine=repr(self.dico_mot_clef['NUME_PAS_TEMPS'])
+       return chaine