From 487280520e4dd4ebd84f2b1f9d2e3f120c1f2ba1 Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Mon, 5 Nov 2018 18:36:04 +0100 Subject: [PATCH] Pour sauvegarde --- Efi2Xsd/AccasXsd.py | 23 +++--- Efi2Xsd/MCAccasXsd.py | 187 +++++++++++++++++------------------------- Efi2Xsd/balises.py | 5 +- 3 files changed, 92 insertions(+), 123 deletions(-) diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index 4483ad41..1b35aba0 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -10,18 +10,18 @@ sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) # ds l init du SIMP il manque siValide et fenetreIhm -from mapDesTypes import dictSIMPEficasXML, dictSIMPXMLEficas -from mapDesTypes import dictFACTEficasXML, dictFACTXMLEficas -from mapDesTypes import dictPROCEficasXML, dictPROCXMLEficas -from mapDesTypes import dictOPEREficasXML, dictOPERXMLEficas -from mapDesTypes import dictBLOCEficasXML, dictBLOCXMLEficas -from mapDesTypes import dictPourCast, dictNomsDesTypes -from mapDesTypes import listeParamDeTypeTypeAttendu, listeParamDeTypeStr, dictPourCast -from mapDesTypes import listeParamTjsSequence, listeParamSelonType -from mapDesTypes import Tuple +from .mapDesTypes import dictSIMPEficasXML, dictSIMPXMLEficas +from .mapDesTypes import dictFACTEficasXML, dictFACTXMLEficas +from .mapDesTypes import dictPROCEficasXML, dictPROCXMLEficas +from .mapDesTypes import dictOPEREficasXML, dictOPERXMLEficas +from .mapDesTypes import dictBLOCEficasXML, dictBLOCXMLEficas +from .mapDesTypes import dictPourCast, dictNomsDesTypes +from .mapDesTypes import listeParamDeTypeTypeAttendu, listeParamDeTypeStr, dictPourCast +from .mapDesTypes import listeParamTjsSequence, listeParamSelonType +from .mapDesTypes import Tuple -from balises import * +from .balises import * # ----------------- class X_definition: @@ -98,7 +98,7 @@ class X_definitionComposee (X_definition): # pour accepter les PROC et ... # if self.aCreer : - self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb,self.minOccurs,self.maxOccurs) + self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb) texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils() self.texteComplexe = texteComplexeVenantDesFils + self.texteComplexe self.texteComplexe += finTypeCompo @@ -226,6 +226,7 @@ class X_SIMP (X_definition): # il faut gerer les types tuple et fichier if hasattr(self.type[0], 'label') and self.type[0].label == "Tuple" : return ('XXXXXXXX') + print (self.type[0]) return dictNomsDesTypes[self.type[0]] def traduitValMinValMax(self): diff --git a/Efi2Xsd/MCAccasXsd.py b/Efi2Xsd/MCAccasXsd.py index 21b7f318..89fa46f6 100755 --- a/Efi2Xsd/MCAccasXsd.py +++ b/Efi2Xsd/MCAccasXsd.py @@ -16,22 +16,43 @@ import pyxb.binding.basis class X_OBJECT: # ------------- - def deletePyxbObject(self): - print ('----------- deletePyxbObject', self.nom) - indice = 0 + def delObjPyxb(self): + print ('----------- delObjPyxb', self.nom) trouve = False + listeArg=[] for i in self.perePyxb.objPyxb.orderedContent(): - if id(self.objPyxb) == id(i._Content__value) : trouve = True ;break - indice = indice + 1 + if id(self.objPyxb) == id(i._Content__value) : trouve = True ;continue + listeArg.append(i._Content__value) if not trouve : print ('objet pas trouve') - print (self.perePyxb.objPyxb.description) - del self.perePyxb.objPyxb.__dict__[self.nom] - print (self.perePyxb.objPyxb.__delattr__) - #delattr(self.perePyxb.objPyxb,self.nom) - # PNPN + grandPere=self.perePyxb.perePyxb + ancienObjPerePyxb=self.perePyxb.objPyxb + + print (listeArg) + nvlObjPerePyxb=self.perePyxb.maClasseModeleMetier(*listeArg) + print (nvlObjPerePyxb) + self.perePyxb.objPyxb=nvlObjPerePyxb + self.perePyxb.objPyxb.objAccas=ancienObjPerePyxb.objAccas + + print (self.nom, ' a pour gp ', grandPere) + if grandPere : grandPere.reconstruitAvecNvlObj(ancienObjPerePyxb,nvlObjPerePyxb) + print ('----------- fin delObjPyxb', self.nom) - print ('delattr', self.perePyxb.objPyxb,self.nom) - del self.perePyxb.objPyxb.orderedContent()[indice] + def addObjPyxb(self,indiceDansLeContenu): + print ('addObjPyxb ds X_OBJECT') + + + def reconstruitAvecNvlObj(self, ancienObj,nvlObj): + print ('reconstruitAvecNvlObj pour', self, self.nom, ancienObj,nvlObj) + listeArg=[] + for i in self.objPyxb.orderedContent(): + if id(ancienObj) == id(i._Content__value) : listeArg.append(nvlObj) + else : listeArg.append(i._Content__value) + nouveauMoiPyxb=self.maClasseModeleMetier(*listeArg) + nouveauMoiPyxb.objAccas=self + self.objPyxb=nouveauMoiPyxb + if self.perePyxb : self.perePyxb.reconstruitAvecNvlObj(self.objPyxb,nouveauMoiPyxb) + + class X_MCSIMP(X_OBJECT): @@ -43,12 +64,13 @@ class X_MCSIMP(X_OBJECT): if not self.cata.modeleMetier : return #print ('X_MCSIMP buildObjPyxb', self.nom, self,self.valeur) #if self.nom == 'diameter' : - # traceback.print_stack() + # traceback.print_stack() # print ('****************************************************') - # print ('objPyxbDeConstruction', self.objPyxbDeConstruction) + #print ('objPyxbDeConstruction', self.objPyxbDeConstruction) #if self.objPyxbDeConstruction == None : print (self.nom, ' pas de pyxb') if self.objPyxbDeConstruction != None : self.objPyxb = self.objPyxbDeConstruction + self.objPyxb.objAccas=self self.maClasseModeleMetier =type(self.objPyxb) #print (self.maClasseModeleMetier) self.objPyxbDeConstruction = None @@ -61,20 +83,20 @@ class X_MCSIMP(X_OBJECT): if self.valeur != None : self.objPyxb=self.maClasseModeleMetier(self.valeur) elif self.definition.into != None and 'TXM' in self.definition.type : self.objPyxb = None else : self.objPyxb=self.maClasseModeleMetier(); - #self.filsPyxb=None - #print ('X_MCSIMP', self.nom, self.objPyxb) + if self.objPyxb : self.objPyxb.objAccas=self + #print ('X_MCSIMP', self.nom, self.objPyxb, ) #print ('fin X_MCSIMP', self.objPyxb, self.nom,self) def setValeurObjPyxb(self,newVal): - print ('dans setValeurObjPyxb MCSIMP') if not self.cata.modeleMetier : return - # print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb) + #print ('dans setValeurObjPyxb MCSIMP ', self.nom) + #print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb) if newVal != None : nvlObj=self.maClasseModeleMetier(newVal) else : nvlObj=self.maClasseModeleMetier() self.val=newVal + setattr(self.perePyxb.objPyxb,self.nom,nvlObj) - print ('setattr', self.perePyxb.objPyxb,self.nom) trouve=False indice=0 for i in self.perePyxb.objPyxb.orderedContent(): @@ -86,78 +108,28 @@ class X_MCSIMP(X_OBJECT): indice+=1 if not trouve : print ('Attention souci au changement de valeur de ', self.nom) self.objPyxb=nvlObj - print ('iiiiiiiiiiiiiiiiiiiiiiiiiiiiii', nvlObj, id(nvlObj)) - #for i in self.perePyxb.objPyxb.orderedContent(): - # print ('ds le for pour i') - # print (i._Content__value) - # print (id(i._Content__value)) - # print (type((i._Content__value))) - # if id(i._Content__value) == id(self.objPyxb) : break - # indexOC +=1 - - #maValeur = getattr(self.perePyxb.objPyxb, self.nom) - #print ('je change', indexOC) - #if isinstance(maValeur, pyxb.binding.basis.simpleTypeDefinition): - #if 1 : - # print ('jkjkljkljklj') - # setattr(self.perePyxb.objPyxb,self.nom,nvlObj) - # self.perePyxb.objPyxb.orderedContent()[indexOC]=self.perePyxb.objPyxb.orderedContent()[-1] - # del(self.perePyxb.objPyxb.orderedContent()[-1]) - #print ('apres',self.nom, self.perePyxb.objPyxb.orderedContent()) - #else : - # index=0 - # trouve=False - # try : - # for i in maValeur: - # if id(i) == id(self.objPyxb) :trouve = True ; break - # index=index+1 - # maValeur[index]=nvlObj - # self.perePyxb.objPyxb.orderedContent()[indexOC]._Content__value=nvlObj - # except : pass - # if not trouve : print (self.nom , 'pas trouve') - - #print ('arret programme'); exit() - - #print ('id objPyxb',id(self.objPyxb)) - #print ('id objPyxb[0]',id(self.objPyxb[0])) - #print ('id elt ', id(self.objPyxb._element), self.objPyxb._element, type(self.objPyxb._element), type(self.objPyxb._element())) - #print (' perePyxb _ElementMap') - #print (self.perePyxb.objPyxb._ElementMap) - #index=0 - #for i in self.perePyxb.objPyxb._ElementMap.keys() : - # print (id(i), ' ', id(self.perePyxb.objPyxb._ElementMap[i])) - #print (dir(self.perePyxb.objPyxb._ElementMap[i])) - # print (id(self.perePyxb.objPyxb._ElementMap[i])) -# index=index+1 - #print (' objPyxb monBinding id') - #monBinding = getattr(self.perePyxb.objPyxb, self.nom) - #for i in monBinding : print id(i) - #print (' perePyxb orderedContent') - #for i in self.perePyxb.objPyxb.orderedContent(): - # print id(i._Content__value) - # print (i._Content__value, type(i._Content__value)) - #print (' perePyxb orderedContent') - #for i in self.perePyxb.objPyxb.content(): print id(i) - - #print (self.perePyxb.objPyxb.orderedContent()) - #print (monBinding) + self.objPyxb.objAccas=self + - def addPyxbObject(self, indiceDsLeContenu): + def addObjPyxb(self, indiceDsLeContenu): if not self.cata.modeleMetier : return + print ('addObjPyxb : ajout de ', self.nom, 'en ', indiceDsLeContenu) # adherence Accas sur le parent parent=self.parent while (parent.isBLOC() ): parent=parent.parent self.perePyxb=parent + print ('dans le perePyxb', self.perePyxb.nom) + print (dir(self.perePyxb)) self.monNomClasseModeleMetier='T_'+self.nom self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) nvlObj=self.maClasseModeleMetier() - print ('setattr', self.perePyxb.objPyxb,self.nom) setattr(self.perePyxb.objPyxb,self.nom,nvlObj) tampon=self.perePyxb.objPyxb.orderedContent()[-1] self.objPyxb = nvlObj + self.objPyxb.objAccas=self indexOC=-1 longueur=len(self.perePyxb.objPyxb.orderedContent()) for i in reversed(range(longueur)): @@ -166,30 +138,13 @@ class X_MCSIMP(X_OBJECT): self.perePyxb.objPyxb.orderedContent()[indiceDsLeContenu]=tampon - #for i in self.perePyxb.objPyxb.orderedContent() : - # print (i._Content__value, type(i._Content__value)) - #print ('----------------') - - #print self.perePyxb.objPyxb.orderedContent() - #for i in self.perePyxb.objPyxb.orderedContent(): - # print ('valeur de ', i) - # print (i._Content__value) - # print (type(i._Content__value)) - # if isinstance(i._Content__value, self.maClasseModeleMetier) : - # print dir(i._Content__value) - # self.objPyxb = i._Content__value - # setattr(self.perePyxb.objPyxb, self.nom, nvlObj) - # self.perePyxb.objPyxb.orderedContent()[indexOC]=self.perePyxb.objPyxb.orderedContent()[-1] - # del(self.perePyxb.objPyxb.orderedContent()[-1]) - # indexOC+=1 - #PNPNPNPNPNPNPNPNP class X_MCCOMPO(X_OBJECT) : # ------------------------- # def buildObjPyxb(self,mc_list) : #print ('________________________________________________') - #print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list) + print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list) if not self.cata.modeleMetier : return self.listArg=[] @@ -203,7 +158,7 @@ class X_MCCOMPO(X_OBJECT) : else : self.listArg.append(objAccas.objPyxb) objAccas.perePyxb=self - print (objAccas.nom ,' a pour pere Pyxb', self, self.nom) + #print (objAccas.nom ,' a pour pere Pyxb', self, self.nom) self.monNomClasseModeleMetier='T_'+self.nom self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) @@ -213,13 +168,13 @@ class X_MCCOMPO(X_OBJECT) : #print ('je passe dans le if pour ', self.nom, self.objPyxb, self) else : self.objPyxb=self.maClasseModeleMetier(*self.listArg) - #print ('Fin __________ ', self.nom, self.objPyxb) + self.objPyxb.objAccas=self #print ('X_MCCOMPO', self.nom, self.objPyxb) #print ('_______________________________________') - def deletePyxbObject(self): + def delObjPyxb(self): print ('******************************************') - print ('je passe ds deletePyxbObject pour ', self, self.nom) + print ('je passe ds delObjPyxb pour ', self, self.nom) print (self.perePyxb) print (dir(self)) print ('******************************************') @@ -233,11 +188,11 @@ class X_MCCOMPO(X_OBJECT) : for objFils in fils : fils.perePyxb=self self.listArg.append(fils.objPyxb) - #print (fils.nom ,' a pour pere Pyxb', self, self.nom) + #print (fils.nom ,' est un MCLIST et a pour pere Pyxb', self, self.nom) else : self.listArg.append(fils.objPyxb) fils.perePyxb=self - #print (fils.nom ,' a pour pere Pyxb', self, self.nom) + #print (fils.nom ,' est un SIMP a pour pere Pyxb', self, self.nom) @@ -249,7 +204,7 @@ class X_MCBLOC (X_MCCOMPO): # mise a none ? le bloc n a pas d existence en pyxb self.perePyxb=None #print ('_______________________________________') - #print ('X_MCBLOC buildObjPyxb', self.nom, self, mc_list) + print ('X_MCBLOC buildObjPyxb', self.nom, self, mc_list) # on rattache ses fils au bloc mais leur pere sera ensuite le MCCOMPO qui contient le bloc # Pas sur d en avoir besoin du filsPyxb self.filsPyxb=[] @@ -267,13 +222,8 @@ class X_MCLIST (X_MCCOMPO): # -------------------------- def buildObjPyxb(self,mc_list): - #print ('__________________________________________________________________') - #print ('X_MCLIST buildObjPyxb traite ds X_MCLIST', self.nom, self) - #print ('on ne fait rien pour les MCLISTs, cela sera fait dans chaque MCFACT') - #print ('__________________________________________________________________') pass - # detruire la methode suivante #def build2ObjPyxb(self,mc_list): # print ('_______________________________________') # print ('X_MCLIST buildObjPyxb traite ds X_MCLIST', self.nom, self) @@ -318,22 +268,39 @@ class X_JDC (X_MCCOMPO): def __init__(self): #print ('_______________________________________') #print ('X_JDC buildObjPyxb', self) + self.perePyxb=None if not self.cata.modeleMetier : return self.monNomClasseModeleMetier=self.code self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) self.objPyxb=self.maClasseModeleMetier() + self.objPyxb.objAccas=self pyxb.GlobalValidationConfig._setContentInfluencesGeneration(pyxb.GlobalValidationConfig.ALWAYS) pyxb.GlobalValidationConfig._setInvalidElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) pyxb.GlobalValidationConfig._setOrphanElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) #print ('fin buildObjPyxb _______________________________________') - def enregistreEtapePyxb(self,etape): + def enregistreEtapePyxb(self,etape,indice=0): # OK seulement si sequence (choice ? ...) + # 01 11 2018 + # ne fonctionne pas : a reecrire avec les fonctions addObjPyxb et ReconstruitPerePyxb + print ( 'hhhhhhhhhhhhhhh enregistreEtapePyxb hhhhhhhhhhhhhhhhhhhhhhhhh') + print ('enregistre ds ',self, etape.nom, 'indice = ', indice) if not self.cata.modeleMetier : return - print ('enregistreEtapePyxb' , etape) self.objPyxb.append(etape.objPyxb) + print (self.objPyxb.orderedContent()) + if indice != (len(self.objPyxb.orderedContent()) -1) : + tampon=self.objPyxb.orderedContent()[-1] + for i in reversed(range(len(self.objPyxb.orderedContent()))): + self.objPyxb.orderedContent()[i]=self.objPyxb.orderedContent()[i-1] + if i == indice + 1 : break + self.objPyxb.orderedContent()[indice]=tampon + + print (self.objPyxb.orderedContent()) etape.perePyxb = self - #self.toXml() + try: + self.objPyxb.validateBinding() + except pyxb.ValidationError as e: + print(e.details()) def toXml(self): if not self.cata.modeleMetier : return @@ -358,7 +325,7 @@ class X_JDC (X_MCCOMPO): objAccasEtape=maClasseAccas(**(objEtape.dictArgs)) # attention objAccasEtape = None normal (cf buildSd) - #print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh') + print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh') #print (objEtape , type(objEtape)) #print (objEtape.dictPyxb) #print (maClasseAccas) diff --git a/Efi2Xsd/balises.py b/Efi2Xsd/balises.py index 4f2a4636..f9bf0c7b 100644 --- a/Efi2Xsd/balises.py +++ b/Efi2Xsd/balises.py @@ -1,4 +1,4 @@ -texteDebut='\n' +texteDebut='\n\n' texteFin='' # SIMP @@ -9,7 +9,8 @@ finTypeSimpleWithInto = '\t\t\n\t\n' eltDsSequence = '\t\t\t\n' # COMPO -debutTypeCompo = '\t\n\t\t\n' +#debutTypeCompo = '\t\n\t\t\n' +debutTypeCompo = '\t\n\t\t\n' finTypeCompo = '\t\t\n\t\n' eltCompoDsSequence = '\t\t\t\n' eltCompoDsSequenceSiProc = '\t\t\t\n' -- 2.39.2