From 426411314f674c956bd1648c5caac19b82b3882c Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Fri, 12 Apr 2019 17:47:29 +0200 Subject: [PATCH] dump des xsd et xsd augmente --- Efi2Xsd/AccasXsd.py | 85 ++++++++++++++++++++++++++------------------- Efi2Xsd/balises.py | 70 +++++++++++++++++++++---------------- 2 files changed, 90 insertions(+), 65 deletions(-) diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index adbf9ead..a075b0d5 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -76,7 +76,7 @@ class X_definition: # ---------------------------------------- class X_definitionComposee (X_definition): -# ---------------------------------------- +# ------------------------------------------ def CreeTexteComplexeVenantDesFils(self): texteComplexeVenantDesFils="" @@ -97,7 +97,7 @@ class X_definitionComposee (X_definition): fichierDejaDumpe = True return texteComplexeVenantDesFils - def dumpXsd(self): + def dumpXsd(self, inExtension=False): #print ('------------------------------------------------') #print ('dumpXsd de ' , self.nom) if PourTraduction : print (self.nom) @@ -111,9 +111,14 @@ class X_definitionComposee (X_definition): # if self.aCreer : self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb) + if inExtension : self.texteComplexe += debutEtension.format(self.code) + self.texteComplexe += debutTypeCompoSeq texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils() self.texteComplexe = texteComplexeVenantDesFils + self.texteComplexe - if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompo + if not isinstance(self,X_OPER ) : + self.texteComplexe += finTypeCompo + if inExtension : self.texteComplexe += finExtension + self.texteComplexe += finTypeCompoSeq else : self.texteComplexe = "" @@ -125,7 +130,7 @@ class X_definitionComposee (X_definition): # ______________________ # valable pour PROC et OPER self.minOccurs = 0 - self.maxOccurs = "unbounded" + self.maxOccurs = 1 def compare(self,autreMC): if self.label != autreMC.label : return False @@ -262,22 +267,6 @@ class X_SIMP (X_definition): self.texteSimple += fermeSimpleType - #if self.max > 1 : self.isListe=True - #else : self.isListe =False - #if self.aCreer == True : - # if self.isListe : self.texteSimple = debutTypeSimpleListe.format(self.nomDuTypePyxb, self.nomDuTypeDeBase) - # else : self.texteSimple = debutTypeSimple.format (self.nomDuTypePyxb, self.nomDuTypeDeBase) - # if self.into != None: - # self.texteSimple = self.texteSimple + ">\n" - # for val in self.into : - # self.texteSimple += withInto.format(val) - # self.texteSimple += finWithInto - # else : - # self.texteSimple += fermeBalise - # self.texteSimple += finTypeSimple - #else : - # le type existe deja - def traduitType(self): # il faut traduire le min et le max @@ -286,7 +275,7 @@ class X_SIMP (X_definition): if hasattr(self.type[0], 'ntuple') : return ('XXXXXXXX') if not (self.type[0] in list(dictNomsDesTypes.keys())) : - if (isinstance(self.type[0], Accas.ASSD) or issubclass(self.type[0], Accas.ASSD)) : return 'string' + if (isinstance(self.type[0], Accas.ASSD) or issubclass(self.type[0], Accas.ASSD)) : return 'xs:string' else : return ('YYYYY') return dictNomsDesTypes[self.type[0]] @@ -317,14 +306,10 @@ class X_JDC_CATA : #----------------- def dumpXsd(self): - - #for name, obj in inspect.getmembers(self.module): - # if inspect.isclass(obj): - # if issubclass(obj,Accas.UserASSD) : - # source = inspect.getsourcefile(obj) - # if source.split('/')[-1] != "A_ASSD.py" : - # typeASSD= 'UserASSD' - # textDeclaration += debutAccasClass.format('T_'+obj.__name__,typeASSD) + cata = CONTEXT.getCurrentCata() + if self.fichierSource != self.module.__file__ : + self.dumpDifferenceModuleMetier() + return self.texteSimple = "" self.texteComplexe = "" self.nomDuTypePyxb='T_'+self.code @@ -335,8 +320,10 @@ class X_JDC_CATA : self.texteSimple += commande.texteSimple self.texteSimple += commande.texteComplexe self.texteCata += commande.texteElt - self.texteCata += finTypeCata - self.texteElt=eltCata.format(self.code,self.code, self.nomDuTypePyxb) + self.texteSimple += TypeEtEltAbstraitCodeSpec.format(self.code) + self.texteCata += EltCodeSpecDsCata.format(self.code) + self.texteCata += finTypeCata + self.texteElt = eltCata.format(self.code,self.code, self.nomDuTypePyxb) self.texteXSD = texteDebut.format(self.code,self.code,self.code) #self.texteXSD += textDeclaration @@ -344,12 +331,8 @@ class X_JDC_CATA : self.texteXSD += self.texteCata self.texteXSD += self.texteElt self.texteXSD += texteFin - #print (self.texteSimple) - #print (self.texteCata) - #print (self.texteElt) print (self.texteXSD) dico = {} - cata = CONTEXT.getCurrentCata() for k in list(cata.dictTypesXSD.keys()): if len(cata.dictTypesXSD[k]) > 1: index=0 @@ -364,3 +347,35 @@ class X_JDC_CATA : #pprint.pprint(dico) + def dumpDifferenceModuleMetier(self): + fichierSourceExt=os.path.basename(self.fichierSource) + fichierSource, extension=os.path.splitext(fichierSourceExt) + + allClassFromVimp=[] + o=__import__(fichierSource,{},{}) + for k,d in inspect.getmembers(o): + allClassFromVimp.append(k) + + allClassToDump=[] + for key, data in inspect.getmembers(self.module): + if key in allClassFromVimp : continue + if key != "modeleMetier" : allClassToDump.append(data) + + self.texteSimple = "" + self.texteComplexe = "" + self.texteCata = texteDebut.format(self.code,self.code,self.code) + self.texteCata += includeCata.format(self.code) + self.texteElt = "" + + for c in allClassToDump : + if (isinstance(c, Accas.ETAPE)) : print (c, 'aDumper') + c.code=self.code + c.dumpXsd(inExtension=True) + self.texteSimple += c.texteSimple + self.texteSimple += c.texteComplexe + self.texteElt += c.texteElt + #print (self.texteCata) + #print (self.texteSimple) + #print (self.texteElt) + self.texteXSD = self.texteCata+'\n'+self.texteSimple+'\n'+self.texteElt+'\n'+texteFin+'\n' + print (self.texteXSD) diff --git a/Efi2Xsd/balises.py b/Efi2Xsd/balises.py index 73e6b82e..ac8cc1ef 100644 --- a/Efi2Xsd/balises.py +++ b/Efi2Xsd/balises.py @@ -1,50 +1,60 @@ -texteDebut='\n\n' -texteFin='' -fermeBalise = "/>" +#texteDebut='\n\n' +texteDebut='\n\n' +texteFin='' +texteDebutCataSpecifique='\n' # SIMP -debutSimpleType = '\t\n' -fermeSimpleType = '\t\n' -debutRestrictionBase = '\t\t\n' -fermeRestrictionBase = '\t\t\n' -enumeration = '\t\t\t\n' -maxInclusiveBorne = '\t\t\t\n' -minInclusiveBorne = '\t\t\t\n' +debutSimpleType = '\t\n' +fermeSimpleType = '\t\n' +debutRestrictionBase = '\t\t\n' +fermeRestrictionBase = '\t\t\n' +enumeration = '\t\t\t\n' +maxInclusiveBorne = '\t\t\t\n' +minInclusiveBorne = '\t\t\t\n' -debutTypeSimpleListe = '\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n' -finTypeSimpleListe = '\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n' -fermeBalisesMileu = '\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t \n' +debutTypeSimpleListe = '\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n' +finTypeSimpleListe = '\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n' +fermeBalisesMileu = '\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t \n' -maxLengthTypeSimple = '\t\t\t\n' -minLengthTypeSimple = '\t\t\t\n' -eltDsSequence = '\t\t\t\n' -eltWithDefautDsSequence = '\t\t\t\n' +maxLengthTypeSimple = '\t\t\t\n' +minLengthTypeSimple = '\t\t\t\n' +eltDsSequence = '\t\t\t\n' +eltWithDefautDsSequence = '\t\t\t\n' # COMPO -#debutTypeCompo = '\t\n\t\t\n' -debutTypeCompo = '\t\n\t\t\n' -finTypeCompo = '\t\t\n\t\n' -eltCompoDsSequence = '\t\t\t\n' +debutTypeCompo = '\t\n' +debutTypeCompoSeq = '\t\t\n' +finTypeCompo = '\t\t\n' +finTypeCompoSeq = '\t\n' +eltCompoDsSequence = '\t\t\t\n' # BLOC -debutTypeSubst = '\t \n\t\t\n' -finTypeSubst = '\t\t\n\t\n' -substDsSequence = '\t\t\t\n' +debutTypeSubst = '\t \n\t\t\n' +finTypeSubst = '\t\t\n\t\n' +substDsSequence = '\t\t\t\n' # User OR ASSD -operAttributeName = '\t\t\n' -attributeTypeForASSD = '\t\t\n' -attributeTypeUtilisateurName = '\t\t\n' +operAttributeName = '\t\t\n' +attributeTypeForASSD = '\t\t\n' +attributeTypeUtilisateurName = '\t\t\n' #keyRefDeclaration ='\n\t \n\t\t\n\t\t\n\t\n' # CATA -debutTypeCata = '\t\n\t\t\n' -finTypeCata = '\t\t\n\t ' -eltCata = '\t\n' +debutTypeCata = '\t\n\t\t\n' +finTypeCata = '\t\t\n\t\n' +finSchema = '' +eltCata = '\t\n' +TypeEtEltAbstraitCodeSpec = '\t\n\t\n' +EltCodeSpecDsCata='\t\t\t\n' +includeCata = '\t\n\n' + +# EXTENSION +debutEtension = '\t\t\n\t\t\n' +finExtension = '\t\t\n\t\t\n' if __name__ == '__main__' : -- 2.39.2