From c5741dab4fa335226757517c2f1643f4042e2286 Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Wed, 16 May 2018 10:04:29 +0200 Subject: [PATCH] 1ere version substitution --- Efi2Xsd/AccasXsd.py | 51 +++++++++++++++++++++++++++++++++++------ Efi2Xsd/MCAccasXsd.py | 6 ++--- Efi2Xsd/balises.py | 19 +++++++++++++-- Efi2Xsd/readerEfiXsd.py | 16 ++++++++++--- 4 files changed, 77 insertions(+), 15 deletions(-) diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index e05e7be4..2d800504 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -70,6 +70,8 @@ class X_definitionComposee (X_definition): self.traduitMinMax() self.texteElt=eltDsSequence.format(self.nom,self.code,self.nomDuTypeCree,self.minOccurs,self.maxOccurs) + #print (self.texteComplexe) + #print ('------------------------------------------------') def traduitMinMax(self): # ____________________ @@ -100,7 +102,29 @@ class X_PROC (X_definitionComposee): class X_BLOC (X_definitionComposee): #----------------------------------- def dumpXsd(self): - X_definitionComposee.dumpXsd(self) + #print ('------------------------------------------------') + #print ('dumpXsd de ' , self.nom) + + self.getCode() + self.nomDuTypeCree = self.nomSimple() + self.texteSimple = "" # on n ajoute pas de type simple + + self.texteComplexe = debutTypeSubst.format(self.nomDuTypeCree) + texteComplexeVenantDesFils="" + for nom in self.ordre_mc: + mcFils = self.entites[nom] + mcFils.dumpXsd() + self.texteComplexe += mcFils.texteElt + self.texteSimple += mcFils.texteSimple + texteComplexeVenantDesFils += mcFils.texteComplexe + self.texteComplexe += finTypeSubst + self.texteComplexe = texteComplexeVenantDesFils + self.texteComplexe + + self.traduitMinMax() + # Pour les blocs le minOccurs vaut 0 bien sur + self.minOccurs=0 + self.texteElt=substDsSequence.format(self.code,self.nomDuTypeCree,self.minOccurs,self.maxOccurs) + #print ('------------------------------------------------') #-------------------------------- class X_SIMP (X_definition): @@ -114,7 +138,13 @@ class X_SIMP (X_definition): #self.traduitValMinValMax() self.nomDuTypeDeBase = self.traduitType() self.nomDuTypeCree = self.nomSimple() - self.texteSimple = typeSimple.format(self.nomDuTypeCree, self.nomDuTypeDeBase) + if self.into != None: + self.texteSimple = debutTypeSimpleWithInto.format (self.nomDuTypeCree, self.nomDuTypeDeBase) + for val in self.into : + self.texteSimple += typeSimpleWithInto.format(val) + self.texteSimple += finTypeSimpleWithInto + else : + self.texteSimple = typeSimple.format(self.nomDuTypeCree, self.nomDuTypeDeBase) self.texteComplexe = "" # on se sert des listes si maxOccurs est > 0 @@ -149,6 +179,7 @@ class X_JDC_CATA : #----------------- def dumpXsd(self): + self.texteSimple = "" self.texteComplexe = "" self.nomDuTypeCree='T_'+self.code @@ -160,9 +191,15 @@ class X_JDC_CATA : self.texteSimple += commande.texteComplexe self.texteCata += commande.texteElt self.texteCata += finTypeCata - self.texteElt=eltCata.format(self.code, self.nomDuTypeCree) - print (self.texteSimple) - print (self.texteComplexe) - print (self.texteCata) - print (self.texteElt) + self.texteElt=eltCata.format(self.code,self.code, self.nomDuTypeCree) + + self.texteXSD = texteDebut.format(self.code,self.code,self.code) + self.texteXSD += self.texteSimple + self.texteXSD += self.texteCata + self.texteXSD += self.texteElt + self.texteXSD += texteFin + #print (self.texteSimple) + #print (self.texteCata) + #print (self.texteElt) + print (self.texteXSD) diff --git a/Efi2Xsd/MCAccasXsd.py b/Efi2Xsd/MCAccasXsd.py index eb20219c..79ee53d5 100755 --- a/Efi2Xsd/MCAccasXsd.py +++ b/Efi2Xsd/MCAccasXsd.py @@ -13,7 +13,7 @@ class X_MCSIMP: def buildObjPyxb(self) : if not self.cata.modeleMetier : return - #print ('X_MCSIMP buildObjPyxb', self.nom, self) + print ('X_MCSIMP buildObjPyxb', self.nom, self) self.monNomDeClasseModeleMetier='T_'+self.nom self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) if self.val != None : self.objPyxb=self.maClasseModeleMetier(self.val) @@ -45,8 +45,9 @@ class X_MCCOMPO: if isinstance(objAccas,MCList) : for mcfact in objAccas : listArg.append(mcfact.objPyxb) else : listArg.append(objAccas.objPyxb) - print (listArg) + #print (listArg) self.objPyxb=self.maClasseModeleMetier(*listArg) + class X_MCFACT : # -------------- @@ -60,7 +61,6 @@ class X_MCFACT : class X_MCLIST: # -------------- - def buildObjPyxb(self,factList): if not self.cata.modeleMetier : return diff --git a/Efi2Xsd/balises.py b/Efi2Xsd/balises.py index c0eee995..0451a0f1 100644 --- a/Efi2Xsd/balises.py +++ b/Efi2Xsd/balises.py @@ -1,13 +1,28 @@ +texteDebut='\n' +texteFin='' + +# SIMP typeSimple = '\t\n\t\t\n\t\n' +debutTypeSimpleWithInto = '\t\n\t\t\n' +typeSimpleWithInto = '\t\t\t\n' +finTypeSimpleWithInto = '\t\t\n\t\n' eltDsSequence = '\t\t\t\n' +# COMPO debutTypeComplexe = '\t\n\t\t\n' finTypeComplexe = '\t\t\n\t\n' +eltCompoDsSequence = '\t\t\t\n' + +# BLOC +debutTypeSubst = '\t minOccurs="{}" maxOccurs="{}"\n\t\t\n' +finTypeSubst = '\t\t\n\t\n' +substDsSequence = '\t\t\t\n' + +# CATA debutTypeCata = '\t\n\t\t\n' finTypeCata = '\t\t\n\t ' - -eltCata = '\n' +eltCata = '\t\n' if __name__ == '__main__' : diff --git a/Efi2Xsd/readerEfiXsd.py b/Efi2Xsd/readerEfiXsd.py index 82883038..c98a16cd 100755 --- a/Efi2Xsd/readerEfiXsd.py +++ b/Efi2Xsd/readerEfiXsd.py @@ -94,6 +94,8 @@ class monSIMP (efficas.T_SIMP, objetDefinitionAccas): #print ("je passe dans explore pour SIMP ", self.nom) self.dictATraiter= dictSIMPXMLEficas self.argumentXMLToEficas() + #print (self.dictArgsEficas) + self.objAccas=A_SIMP.SIMP(**self.dictArgsEficas) self.objAccas.nom=self.nomObj @@ -109,7 +111,6 @@ class monSIMP (efficas.T_SIMP, objetDefinitionAccas): self.traiteLesSequences() - print (self.dictArgsEficas) #self.convertitLesTypes() def attendListe(self): @@ -136,8 +137,15 @@ class monSIMP (efficas.T_SIMP, objetDefinitionAccas): for param in listeParamTjsSequence : if param in self.dictArgsEficas : if listeDeListe == False: - listeDElt=self.dictArgsEficas[param][0].content() + #print ('________________________________') + listeDElt=[] + for i in range(len(self.dictArgsEficas[param])): + # ou typesimple ? + # ici on ne sait pas si on est un type simple ou complexe ? + listeDElt.append(self.dictArgsEficas[param][i].content()[0]) listeRetour=self.convertitListeDsLeBonType(listeDElt) + #print (listeRetour) + #print ('________________________________') self.dictArgsEficas[param]=listeRetour else : listeResultat=[] @@ -268,8 +276,10 @@ class monBLOC(efficas.T_BLOC, objetComposeDefinitionAccas): class monCata(efficas.T_cata): # ------------------------------ def exploreCata(self): + # PNPNPN --> il faut revoir ce mecanisme + self.modeleMetier = None # On positionne le contexte ACCAS - self.JdC = JDC_CATA (code = 'MED', execmodul = None,) + self.JdC = JDC_CATA (code = 'Atmo', execmodul = None,) self.contexteXML={} objAExplorer=self.commandes[0] for obj in objAExplorer.content(): -- 2.39.2