From e7e67cd3d3fafa7f222dd82c0bf806024cd5062e Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Tue, 5 Jun 2018 18:10:55 +0200 Subject: [PATCH] sauvegarde du 5 juin --- Efi2Xsd/MCAccasXsd.py | 128 ++++++++++++++++++++++++++++++++---------- 1 file changed, 97 insertions(+), 31 deletions(-) mode change 100644 => 100755 Efi2Xsd/MCAccasXsd.py diff --git a/Efi2Xsd/MCAccasXsd.py b/Efi2Xsd/MCAccasXsd.py old mode 100644 new mode 100755 index eb20219c..9ac25950 --- a/Efi2Xsd/MCAccasXsd.py +++ b/Efi2Xsd/MCAccasXsd.py @@ -6,6 +6,12 @@ import types sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) +import pyxb +#import pyxb.binding +#import pyxb.binding.saxer +#import pyxb.utils.utility +#import pyxb.utils.domutils + class X_MCSIMP: @@ -16,6 +22,8 @@ class X_MCSIMP: #print ('X_MCSIMP buildObjPyxb', self.nom, self) self.monNomDeClasseModeleMetier='T_'+self.nom self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) + #print (self.maClasseModeleMetier) + #print (self.val) if self.val != None : self.objPyxb=self.maClasseModeleMetier(self.val) else : self.objPyxb=self.maClasseModeleMetier() #print ('fin X_MCSIMP', self.objPyxb, self.nom,self) @@ -23,12 +31,59 @@ class X_MCSIMP: def setValeurObjPyxb(self,newVal): if not self.cata.modeleMetier : return - print ('setValeurObjPyxb') if newVal != None : nvlObj=self.maClasseModeleMetier(newVal) else : nvlObj=self.maClasseModeleMetier() self.val=newVal + indexOC=0 + print ('avant', self.perePyxb.objPyxb.orderedContent()) + for i in self.perePyxb.objPyxb.orderedContent(): + if id(i._Content__value) == id(self.objPyxb) : break + indexOC +=1 + + maSequence = getattr(self.perePyxb.objPyxb, self.nom) + if isinstance(maSequence, pyxb.binding.basis.simpleTypeDefinition): + print indexOC + #maSequence=nvlObj + setattr(self.perePyxb.objPyxb, self.nom, nvlObj) + print ('milieu',self.perePyxb.objPyxb.orderedContent()) + self.perePyxb.objPyxb.orderedContent()[indexOC]=self.perePyxb.objPyxb.orderedContent()[-1] + del(self.perePyxb.objPyxb.orderedContent()[-1]) + print ('apres',self.perePyxb.objPyxb.orderedContent()) + else : + index=0 + for i in maSequence: + if id(i) == id(self.objPyxb) : break + index=index+1 + maSequence[index]=nvlObj + self.perePyxb.objPyxb.orderedContent()[indexOC]._Content__value=nvlObj + self.objPyxb=nvlObj - setattr(self.parent.objPyxb, self.nom, nvlObj) + + + #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) + class X_MCCOMPO: @@ -36,61 +91,72 @@ class X_MCCOMPO: # def buildObjPyxb(self,mc_list) : if not self.cata.modeleMetier : return - print ('X_MCCOMPO buildObjPyxb', self.nom, self) + #print ('_______________________________________') + #print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list) self.monNomDeClasseModeleMetier='T_'+self.nom self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) listArg=[] for objAccas in mc_list : - from Accas.A_MCLIST import MCList - if isinstance(objAccas,MCList) : - for mcfact in objAccas : listArg.append(mcfact.objPyxb) - else : listArg.append(objAccas.objPyxb) - print (listArg) + listArg.append(objAccas.objPyxb) + objAccas.perePyxb=self + #print ( objAccas.nom, ' a pour perepyxb ' , objAccas.perePyxb.nom) self.objPyxb=self.maClasseModeleMetier(*listArg) + #print ('Fin ', self.nom, self.objPyxb) + #print ('_______________________________________') + -class X_MCFACT : -# -------------- -# Pour un MCFACT : -# le buildObjPyxb sera pris en charge par X_MCLIST -# on ne fait rien +class X_MCLIST (X_MCCOMPO): +# -------------------------- def buildObjPyxb(self,mc_list): + #print ('_______________________________________') + #print ('X_MCLIST buildObjPyxb traite ds X_MCFACT', self.nom, self) + self.monNomDeClasseModeleMetier='T_'+self.nom + self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) + listArg=[] + # MCList est une liste + for nbDeSequence in self : + for objAccas in nbDeSequence.mc_liste : + listArg.append(objAccas.objPyxb) + objAccas.perePyxb=self + #print ( objAccas.nom, ' a pour perepyxb ' , objAccas.perePyxb.nom) + self.objPyxb=self.maClasseModeleMetier(*listArg) + #print ('X_MCFACT', self.nom, self, listArg) + #print ('fin buildObjPyxb traite ds X_MCFACT', self.nom, self) + #print ('_______________________________________') + +class X_MCFACT (X_MCCOMPO): +# ------------------------- +# on gere au niveau du MCLIST + + def buildObjPyxb(self,mc_list): + #print ('_______________________________________') #print ('X_MCFACT buildObjPyxb debut et fin', self.nom, self) + #print ('_______________________________________') pass - -class X_MCLIST: -# -------------- - - def buildObjPyxb(self,factList): - if not self.cata.modeleMetier : return - #print ('X_MCLIST buildObjPyxb', self.nom, self) - - self.monNomDeClasseModeleMetier='T_'+self.nom - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) - for objAccas in factList : - listArg=[] - for objAccasFils in objAccas.mc_liste : - listArg.append(objAccasFils.objPyxb) - objAccas.objPyxb=self.maClasseModeleMetier(*listArg) - #print (objAccas , 'ds MCLIST a pour obj pyxb', objAccas.objPyxb) class X_JDC: # ---------- def __init__(self): + #print ('_______________________________________') #print ('X_JDC buildObjPyxb', self) if not self.cata.modeleMetier : return self.monNomDeClasseModeleMetier=self.code self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) self.objPyxb=self.maClasseModeleMetier() - #print ('fin X_JDC buildObjPyxb', self.objPyxb, self) + pyxb.GlobalValidationConfig._setContentInfluencesGeneration(pyxb.GlobalValidationConfig.ALWAYS) + pyxb.GlobalValidationConfig._setInvalidElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) + pyxb.GlobalValidationConfig._setOrphanElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) + def enregistreEtapePyxb(self,etape): # OK seulement si sequence (choice ? ...) - print ('ds enregistreEtapePyxb', etape.nom) + #print ('ds enregistreEtapePyxb', etape.nom) if not self.cata.modeleMetier : return self.objPyxb.append(etape.objPyxb) + etape.perePyxb = self #self.toXml() def toXml(self): -- 2.39.2