From: pascale.noyret Date: Thu, 8 Oct 2020 13:07:02 +0000 (+0200) Subject: partage X-Git-Tag: MDM_V0~6^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f04c1e6dc92d6acea76caa5c38afd17cd788562c;p=tools%2Feficas.git partage --- diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index 3b4d8552..7973942d 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -131,15 +131,19 @@ class X_definition: else : cata.dictTypesXSD[nom].append(self) - def definitNomDuTypePyxb(self,forceACreer=False): - + def definitNomDuTypePyxb(self,debug=False): + + if debug : print ('definitNomDuTypePyxb', self, self.nom,self.nomComplet()) if hasattr(self,'nomDuTypePyxb') : self.aCreer = False; return self.nomDuTypePyxb + #debug=False #except : pass + if debug : print ('definitNomDuTypePyxb traitement pour ', self.nom) self.aCreer = True cata = CONTEXT.getCurrentCata() nom='T_'+self.nom if (hasattr (self, 'nomXML')) and self.nomXML != None : nom='T_'+self.nomXML if not (nom in cata.dictTypesXSD.keys()) : + if debug : print ('definitNomDuTypePyxb encore jamais traite ', self.nom , ' a pour type' , nom) cata.dictTypesXSD[nom] = [self,] self.nomDuTypePyxb=nom return nom @@ -153,7 +157,12 @@ class X_definition: objAComparer=listePossible[indice] if self.compare(objAComparer) : self.nomDuTypePyxb=objAComparer.nomDuTypePyxb - if self.nom=='FactE' : print (2,self.aCreer) + if debug : print ('definitNomDuTypePyxb', self.nom , 'type identique', objAComparer.nomDuTypePyxb ) + # c est nul pour la comparaison mais cela permet d etre ok dans le dictionnaire passe a Accas + cata.dictTypesXSD[nom].append(self) + if self.label != 'SIMP' : + if objAComparer not in list(cata.dictTypesXSDJumeaux.keys()) : cata.dictTypesXSDJumeaux[objAComparer]=[self,] + else : cata.dictTypesXSDJumeaux[objAComparer].append(self) return objAComparer.nomDuTypePyxb indice += 1 self.aCreer = True @@ -432,16 +441,17 @@ class X_compoFactoriseAmbigu(X_definition): # si len(listePourUnion==1) on est deja sorti non ? mc=self.entites[nomMC][0] mc.dumpXsd(dansFactorisation=True,multiple=True,first=first) + # inutile - deja fait plus haut if mc.aCreer : self.texteComplexeVenantDesFils += mc.texteComplexe if mc.aCreer : self.texteSimple += mc.texteSimple else : - for e in listePourUnion : - e.dumpXsd(dansFactorisation=True,multiple=True,first=first) + texteSimpleUnion += '\t'*(indent)+self.entites[nomMC][0].texteSimple + for e in listePourUnion[1:] : + e.dumpXsd(dansFactorisation=True,multiple=True,first=False) # si on ext un mc simple la ligne suivante est inutile # en revanche on ajoute le texte a tous les coups - self.texteComplexeVenantDesFils += e.texteComplexe + #self.texteComplexeVenantDesFils += e.texteComplexe e.metAJourPyxb(nomTypePyxbUnion) - first=first * 0 texteSimpleUnion += '\t'*(indent)+e.texteSimple texteSimpleUnion += finUnion texteSimpleUnion+=fermeSimpleType @@ -755,13 +765,15 @@ class X_SIMP (X_definition): # --> homonymie on peut utiliser genealogie ? self.nomDuTypeDeBase = self.traduitType() - if not multiple : - self.nomDuTypePyxb = self.definitNomDuTypePyxb() + #if not multiple : + # self.nomDuTypePyxb = self.definitNomDuTypePyxb() #if first : self.aCreer = True - elif first : - self.nomDuTypePyxb = self.definitNomDuTypePyxb(forceACreer=1) + #elif first : + #else : + # self.nomDuTypePyxb = self.definitNomDuTypePyxb() #self.aCreer = True #else : print ('multiple and not first', self.aCreer) + self.definitNomDuTypePyxb() @@ -1031,21 +1043,77 @@ class X_JDC_CATA : - #if not PourTraduction : print (self.texteXSD) - dico = {} + # PN : version 0 de la construction des types a remplacer #import pprint #pprint.pprint(cata.dictTypesXSD) + #dicoARemplacer={} + #for k in list(cata.dictTypesXSD.keys()): + # if len(cata.dictTypesXSD[k])==1 : continue + # listeDesFacts=[] + # listeDesBlocs=[] + # listeDesBlocsAmbigus=[] + # for definition in cata.dictTypesXSD[k] : + # if definition.label == 'SIMP' : continue + # if definition.label == 'FACT' : listeDesFacts.append(definition) + # if definition.label == 'BLOC' : listeDesBlocs.append(definition) + # if definition.label == 'BlocAmbigu': listeDesBlocsAmbigus.append(definition) + # print (k,listeDesFacts,listeDesBlocs,listeDesBlocsAmbigus) + # for listeTraitee in listeDesFacts,listeDesBlocs,listeDesBlocsAmbigus: + # if len(listeTraitee) < 2 : continue + # dicoParTypePyxb={} + # for MC in listeTraitee : + # if MC.nomDuTypePyxb in list(dicoParTypePyxb.keys()): dicoParTypePyxb[MC.nomDuTypePyxb].append(MC) + # else : dicoParTypePyxb[MC.nomDuTypePyxb]=[MC,] + # for k in dicoParTypePyxb.keys() : + # if len(dicoParTypePyxb[k]) < 1 : + # dicoARemplacer[k]=dicoParTypePyxb[k][1:] + + import pprint + #pprint.pprint (cata.dictTypesXSDJumeaux) + #for k in cata.dictTypesXSDJumeaux: + # print (k.nom, k.nomComplet()) + # print (cata.dictTypesXSDJumeaux[k][0].nom, cata.dictTypesXSDJumeaux[k][0].nomComplet()) + + #pprint.pprint (cata.dictTypesXSD) + #for k in cata.dictTypesXSD: + # print (k) + # print (cata.dictTypesXSD) + + dico = {} for k in list(cata.dictTypesXSD.keys()): dico[k]={} for definition in cata.dictTypesXSD[k] : - if definition.label == 'BLOC' or definition.label == 'BlocAmbigu':continue - nom=definition.nomComplet() - if k =='T_NumericalMethod' : print (nom) - if definition.nomDuTypePyxb != 'T_'+definition.nom : dico[k][nom]=definition.nomDuTypePyxb + if definition.label == 'BLOC' or definition.label == 'BlocAmbigu':continue + if definition.nomDuTypePyxb == 'T_'+definition.nom : continue + listeATraiter=[definition.geneaCompleteSousFormeDeListe(),] + print (1,listeATraiter) + while listeATraiter != [] : + listeGenea=listeATraiter[0] + listeATraiter=listeATraiter[1:] + print (2,listeATraiter) + txtNomComplet='' + indexMC=0 + for MC in listeGenea: + #print (MC.nom) + #print (listeGenea) + #for e in listeGenea : print (e.nom) + txtNomComplet=txtNomComplet+'_'+MC.nom + if MC in list(cata.dictTypesXSDJumeaux.keys()) : + print ("aCrrer", indexMC) + for MCJumeau in cata.dictTypesXSDJumeaux[MC]: + # attention nvlleGenalogie n a pas de sens en Accas + nvlleGenalogie=listeGenea[:indexMC]+MCJumeau.geneaCompleteSousFormeDeListe() + listeATraiter.append(nvlleGenalogie) + indexMC=indexMC+1 + print (3,listeATraiter) + print ('1',txtNomComplet) + print ('11',definition.nomComplet()) + dico[k][txtNomComplet]=definition.nomDuTypePyxb if dico[k]== {} : del dico[k] - #import pprint - #pprint.pprint(dico) + #dico = {} + import pprint + pprint.pprint(dico) if dico != {} : self.texteXSD += texteAnnotation.format(str(dico)) #import pprint diff --git a/Efi2Xsd/MCAccasXML.py b/Efi2Xsd/MCAccasXML.py index 7f51fb69..b7b896b9 100755 --- a/Efi2Xsd/MCAccasXML.py +++ b/Efi2Xsd/MCAccasXML.py @@ -132,7 +132,9 @@ class X_MCSIMP(X_OBJECT): self.monNomClasseModeleMetier ='T_'+self.nom if hasattr(self.definition,'nomXML') and self.definition.nomXML != None : self.monNomClasseModeleMetier='T_'+self.definition.nomXML if self.monNomClasseModeleMetier in list(self.cata.DicoNomTypeDifferentNomElt.keys()) : - self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.monNomClasseModeleMetier][self.definition.nomComplet()] + nomComplet=self.definition.nomComplet() + if nomComplet in list(self.cata.DicoNomTypeDifferentNomElt[self.monNomClasseModeleMetier].keys()): + self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.monNomClasseModeleMetier][nomComplet] if debug : print ('Pour', self.nom, ' le type est ', self.monNomClasseModeleMetier) self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) if issubclass(self.maClasseModeleMetier, self.cata.modeleMetier.pyxb.binding.basis.STD_union): diff --git a/Noyau/N_ENTITE.py b/Noyau/N_ENTITE.py index 0cd64d55..f33ff613 100644 --- a/Noyau/N_ENTITE.py +++ b/Noyau/N_ENTITE.py @@ -276,6 +276,15 @@ class ENTITE(object): self.txtNomComplet+='_'+qui.nom return self.txtNomComplet + def geneaCompleteSousFormeDeListe(self): + geneaCompleteSousFormeDeListe=[] + qui=self + while hasattr(qui, 'pere' ): + geneaCompleteSousFormeDeListe.append(qui) + qui=qui.pere + geneaCompleteSousFormeDeListe.append(qui) + return geneaCompleteSousFormeDeListe + def addDefinitionMC(self,listeMCAvant,**args): ouChercher=self for mot in listeMCAvant: diff --git a/Noyau/N_JDC_CATA.py b/Noyau/N_JDC_CATA.py index 9ff694e4..3e8141f3 100644 --- a/Noyau/N_JDC_CATA.py +++ b/Noyau/N_JDC_CATA.py @@ -74,7 +74,7 @@ class JDC_CATA(N_ENTITE.ENTITE): CONTEXT.setCurrentCata(self) self.fenetreIhm=None self.dictTypesXSD={} - self.listeDesTypesXSDRedefini=[] + self.dictTypesXSDJumeaux={} self.dictTypesASSDorUserASSDCrees={} self.dictTypesASSDorUserASSDUtilises={} diff --git a/Noyau/N_MCFACT.py b/Noyau/N_MCFACT.py index 3974cdb6..da43a01f 100644 --- a/Noyau/N_MCFACT.py +++ b/Noyau/N_MCFACT.py @@ -42,7 +42,7 @@ class MCFACT(N_MCCOMPO.MCCOMPO): - nom - parent """ - print ('MCFACT', self, val, definition, nom, parent, dicoPyxbDeConstruction) + #print ('MCFACT', self, val, definition, nom, parent, dicoPyxbDeConstruction) #import traceback #traceback.print_stack() self.dicoPyxbDeConstruction=dicoPyxbDeConstruction diff --git a/Tests/MappingAccasXsd/Ambiguite/cata_AmbiguSousAmbigu.py b/Tests/MappingAccasXsd/Ambiguite/cata_AmbiguSousAmbigu.py new file mode 100644 index 00000000..089da4b8 --- /dev/null +++ b/Tests/MappingAccasXsd/Ambiguite/cata_AmbiguSousAmbigu.py @@ -0,0 +1,29 @@ +from Accas import * +JdC = JDC_CATA ( + code = 'Essai', +) + + +LeProc = PROC(nom='LeProc', + + S1 = SIMP(typ='I', statut='o'), + bloc_une = BLOC(condition = "S1 == 1", + Choix = SIMP(typ='TXM', statut='o', into=['A', 'B']), + S2 = SIMP(typ='TXM',), + ), # fin bloc_une + bloc_deux = BLOC(condition = "S1 == 3", + Choix = SIMP(statut='o', typ='TXM', into=['E', 'F']), + bloc_21 = BLOC(condition = "Choix == 'F'", + N1=SIMP(statut='o', typ='TXM', into=['AA', 'BB']), + ),# fin bloc_Field + bloc_22 = BLOC(condition = "Choix == 'E'", + N1=SIMP(statut='o', typ='TXM', into=['SS', 'VV']), + ),# fin bloc_N_particle + ), # fin bloc_deux +) + + + + + +