From: pascale.noyret Date: Tue, 12 Nov 2019 10:20:18 +0000 (+0100) Subject: 1er merge entre la formation Vimmp et la nouvelle façon de declarer les UserASSD X-Git-Tag: V200520bis~111 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5ad26ba2052f45fd0487719bcb8bb1ccf74c758;p=tools%2Feficas.git 1er merge entre la formation Vimmp et la nouvelle façon de declarer les UserASSD --- diff --git a/Accas/A_ETAPE.py b/Accas/A_ETAPE.py index 01ba2a03..aecc47dd 100644 --- a/Accas/A_ETAPE.py +++ b/Accas/A_ETAPE.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from Noyau import N_ETAPE from Validation import V_ETAPE from Ihm import I_ETAPE -from Efi2Xsd.MCAccasXsd import X_MCCOMPO +from Efi2Xsd.MCAccasXML import X_MCCOMPO class ETAPE(I_ETAPE.ETAPE,V_ETAPE.ETAPE,X_MCCOMPO,N_ETAPE.ETAPE): def __init__(self,oper=None,reuse=None,args={}): diff --git a/Accas/A_JDC.py b/Accas/A_JDC.py index d17bd234..3748913d 100644 --- a/Accas/A_JDC.py +++ b/Accas/A_JDC.py @@ -22,7 +22,7 @@ from Noyau import N_JDC from Validation import V_JDC from Extensions import jdc from Ihm import I_JDC -from Efi2Xsd.MCAccasXsd import X_JDC +from Efi2Xsd.MCAccasXML import X_JDC class JDC(jdc.JDC,I_JDC.JDC,X_JDC,V_JDC.JDC,N_JDC.JDC): from .A_ASSD import CO,assd diff --git a/Accas/A_MACRO_ETAPE.py b/Accas/A_MACRO_ETAPE.py index 2bba807e..28a3ce74 100644 --- a/Accas/A_MACRO_ETAPE.py +++ b/Accas/A_MACRO_ETAPE.py @@ -22,7 +22,7 @@ from Noyau import N_MACRO_ETAPE from Validation import V_MACRO_ETAPE from Ihm import I_MACRO_ETAPE from .A_ASSD import CO -from Efi2Xsd.MCAccasXsd import X_MCCOMPO +from Efi2Xsd.MCAccasXML import X_MCCOMPO class MACRO_ETAPE(I_MACRO_ETAPE.MACRO_ETAPE, X_MCCOMPO, diff --git a/Accas/A_MCBLOC.py b/Accas/A_MCBLOC.py index df125d12..5bd5cebd 100644 --- a/Accas/A_MCBLOC.py +++ b/Accas/A_MCBLOC.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from Noyau import N_MCBLOC from Validation import V_MCBLOC from Ihm import I_MCBLOC -from Efi2Xsd.MCAccasXsd import X_MCBLOC +from Efi2Xsd.MCAccasXML import X_MCBLOC class MCBLOC(I_MCBLOC.MCBLOC,N_MCBLOC.MCBLOC,X_MCBLOC,V_MCBLOC.MCBLOC): diff --git a/Accas/A_MCFACT.py b/Accas/A_MCFACT.py index 50fd1a8d..769dcd28 100644 --- a/Accas/A_MCFACT.py +++ b/Accas/A_MCFACT.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from Noyau import N_MCFACT from Validation import V_MCFACT from Ihm import I_MCFACT -from Efi2Xsd.MCAccasXsd import X_MCFACT +from Efi2Xsd.MCAccasXML import X_MCFACT class MCFACT(I_MCFACT.MCFACT,N_MCFACT.MCFACT,X_MCFACT,V_MCFACT.MCFACT): def __init__(self,val,definition,nom,parent,dicoPyxbDeConstruction=None): diff --git a/Accas/A_MCLIST.py b/Accas/A_MCLIST.py index 5554f5ec..922abb89 100644 --- a/Accas/A_MCLIST.py +++ b/Accas/A_MCLIST.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from Noyau import N_MCLIST from Validation import V_MCLIST from Ihm import I_MCLIST -from Efi2Xsd.MCAccasXsd import X_MCLIST +from Efi2Xsd.MCAccasXML import X_MCLIST class MCList(I_MCLIST.MCList,N_MCLIST.MCList,X_MCLIST,V_MCLIST.MCList): diff --git a/Accas/A_MCSIMP.py b/Accas/A_MCSIMP.py index a3c63cb6..7c7ecbca 100644 --- a/Accas/A_MCSIMP.py +++ b/Accas/A_MCSIMP.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from Noyau import N_MCSIMP from Validation import V_MCSIMP from Ihm import I_MCSIMP -from Efi2Xsd.MCAccasXsd import X_MCSIMP +from Efi2Xsd.MCAccasXML import X_MCSIMP class MCSIMP(I_MCSIMP.MCSIMP,N_MCSIMP.MCSIMP,X_MCSIMP,V_MCSIMP.MCSIMP): def __init__(self,val,definition,nom,parent,objPyxbDeConstruction=None): diff --git a/Accas/A_PROC_ETAPE.py b/Accas/A_PROC_ETAPE.py index 7db1db8b..6fdd8361 100644 --- a/Accas/A_PROC_ETAPE.py +++ b/Accas/A_PROC_ETAPE.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from Noyau import N_PROC_ETAPE from Validation import V_PROC_ETAPE from Ihm import I_PROC_ETAPE -from Efi2Xsd.MCAccasXsd import X_MCCOMPO +from Efi2Xsd.MCAccasXML import X_MCCOMPO class PROC_ETAPE(I_PROC_ETAPE.PROC_ETAPE, V_PROC_ETAPE.PROC_ETAPE, diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index 639ef10b..902e4ba3 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -24,7 +24,7 @@ from .mapDesTypes import Tuple PourTraduction = False -from .balises import * +from .balisesXSD import * # ----------------- class X_definition: # ----------------- diff --git a/Efi2Xsd/MCAccasXML.py b/Efi2Xsd/MCAccasXML.py new file mode 100755 index 00000000..84c334dd --- /dev/null +++ b/Efi2Xsd/MCAccasXML.py @@ -0,0 +1,464 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import sys,os +import inspect +import traceback +def trace(): + traceback.print_stack() +#import raw.efficas as efficas +import types + +sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) + +try : + import pyxb + import pyxb.binding + import pyxb.binding.basis + #import pyxb.utils.utility + #import pyxb.utils.domutils +except : pass + +from Accas import A_ASSD + +class X_OBJECT: +# ------------- + + def delObjPyxb(self, debug = False): + if not self.cata.modeleMetier : return + if self.nom == 'Consigne' : return None + trouve = False + + if debug : print self.perePyxb.objPyxb.orderedContent() + if debug : print (map(lambda o:o.value, self.perePyxb.objPyxb.orderedContent())) + + elt=pyxb.binding.basis.ElementContent(self.objPyxb, instance=self.perePyxb.objPyxb, tag=pyxb.namespace.ExpandedName(self.cata.modeleMetier.Namespace, self.nom)) + if debug : print ('element moi = ', elt, 'id de moi = ', id(self.objPyxb)) + if (elt.elementDeclaration.isPlural()): + if debug : print ('je suis Plural') + monIndexInOrderedContent=0 + for c in self.perePyxb.objPyxb.orderedContent(): + if isinstance(c._Content__value,list) and isinstance(c._Content__value[0], type(self.objPyxb)): monIndexInOrderedContent += 1 + + listeObjetsAccas=self.parent.getChild(self.nom,restreint='oui') + if len(listeObjetsAccas) == 1 : monIndex=0 + else : monIndex=listeObjetsAccas.index(self) + + listeObjetsPyxb=getattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key) + listeObjetsPyxb.pop(monIndex) + monIndexInOrderedContent += monIndex + self.perePyxb.objPyxb.orderedContent().pop(monIndexInOrderedContent) + else : + newOrderedContent = [] + for i in self.perePyxb.objPyxb.orderedContent(): + if id(self.objPyxb) == id(i._Content__value) : trouve = True ;continue + newOrderedContent.append(i) + if not trouve : print ('elt a supprimer ', self.nom, 'non trouve') + for i in xrange(len(newOrderedContent)): + self.perePyxb.objPyxb.orderedContent()[i]=newOrderedContent[i] + self.perePyxb.objPyxb.orderedContent().pop(len(newOrderedContent)) + + setattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key,None) + if debug : print (map(lambda o:o.value, self.perePyxb.objPyxb.orderedContent())) + + + + def addObjPyxb(self,indiceDsLeContenu): + if not self.cata.modeleMetier : return + print ('_____________ addObjPyxb ds X_OBJECT', self.nom, indiceDsLeContenu) + # adherence Accas sur le parent + parent=self.parent + while (parent.isBLOC()): + if parent != self.parent : indiceDsLeContenu += parent.rangDsPyxb() + parent=parent.parent + self.perePyxb=parent + + self.objPyxb.objAccas=self + elt=pyxb.binding.basis.ElementContent(self.objPyxb, instance=self.perePyxb.objPyxb, tag=pyxb.namespace.ExpandedName(self.cata.modeleMetier.Namespace, self.nom)) + self.perePyxb.objPyxb.orderedContent().insert(indiceDsLeContenu,elt) + if (elt.elementDeclaration.isPlural()): + # je suis donc un MCList + listeObjetsAccas=self.parent.getChild(self.nom,restreint='oui') + if len(listeObjetsAccas) == 1 : monIndex=1 + else : monIndex=listeObjetsAccas.index(self) + listeObjetsPyxb=getattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key) + listeObjetsPyxb.insert(monIndex,self.objPyxb) + else : + setattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key,self.objPyxb) + + def rangDsPyxb(self): + monRangEnAccas=self.parent.mcListe.index(self) + rangEnPyxb=0 + for frere in self.parent.mcListe[0: monRangEnAccas] : + rangEnPyxb += frere.longueurDsArbre() + return rangEnPyxb + + +class X_MCSIMP(X_OBJECT): +# ----------------------- + + def buildObjPyxb(self) : + if not self.cata.modeleMetier : return + if self.nom == 'Consigne' : return None + if self.nom == 'Spring_Stifness' : + #trace() + print ('Sprinf_Stifness' ,self.valeur) + #print ('X_MCSIMP buildObjPyxb', self.nom, self,self.valeur) + #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) + self.objPyxbDeConstruction = None + else : + self.monNomClasseModeleMetier='T_'+self.nom + if self.nom in list(self.cata.DicoNomTypeDifferentNomElt.keys()) : + self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.nom][self.nomComplet()] + self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) + + if self.valeur != None : self.objPyxb=self.maClasseModeleMetier(self.valeur) + else : self.objPyxb=self.maClasseModeleMetier(_validate_constraints=False); + + if self.objPyxb !=None : self.objPyxb.objAccas=self + #print ('X_MCSIMP', self.nom, self.objPyxb, ) + #print ('fin X_MCSIMP', self.objPyxb, self.nom, self, self.maClasseModeleMetier,self.valeur) + + + def setValeurObjPyxb(self,newVal): + if not self.cata.modeleMetier : return + print ('dans setValeurObjPyxb MCSIMP ', self.nom, newVal) + #print (' self.perePyxb = ', self.perePyxb.nom) + if inspect.isclass(newVal) and issubclass(newVal,A_ASSD) : newVal = newVal.nom + #print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb) + + if newVal != None : nvlObj=self.maClasseModeleMetier(newVal) + # a priori impossible mais ? + else : nvlObj=self.maClasseModeleMetier(_validate_constraints=False) + self.val=newVal + + setattr(self.perePyxb.objPyxb,self.nom,nvlObj) + trouve=False + indice=0 + for i in self.perePyxb.objPyxb.orderedContent(): + if isinstance(i._Content__value, self.maClasseModeleMetier) : + self.perePyxb.objPyxb.orderedContent()[indice]=self.perePyxb.objPyxb.orderedContent()[-1] + del(self.perePyxb.objPyxb.orderedContent()[-1]) + trouve=True + break + indice+=1 + if not trouve : print ('Attention souci au changement de valeur de ', self.nom) + self.objPyxb=nvlObj + self.objPyxb.objAccas=self + #print ('fin du setValeurObjPyxb pour ', self.nom, self.perePyxb.objPyxb.orderedContent()) + + + + +class X_MCCOMPO(X_OBJECT) : +# ------------------------- +# + def buildObjPyxb(self,mc_list) : + if not self.cata.modeleMetier : return + #print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list) + self.listArg=[] + self.dicoArg={} + for objAccas in mc_list : + if objAccas.nature == 'MCBLOC' : + self.exploreBLOC(objAccas) + elif objAccas.nature == 'MCList' : + if objAccas[0].definition.max > 1 : + self.listArg.append(objAccas) # les MCList n ont pas objPyxb + self.dicoArg[objAccas.nom]=[] + for fils in objAccas : + fils.perePyxb=self + self.dicoArg[objAccas.nom].append(fils.objPyxb) + else : + objAccas[0].perePyxb=self + self.dicoArg[objAccas.nom]=objAccas[0].objPyxb + self.listArg.append(objAccas[0].objPyxb) + else : + if objAccas.nom == 'Consigne' : continue + self.listArg.append(objAccas.objPyxb) + self.dicoArg[objAccas.nom]=objAccas.objPyxb + objAccas.perePyxb=self + + #print('X_MCCOMPO -- listArg ---',self.nom,self.listArg) + #print('X_MCCOMPO -- dicoArg ---',self.nom,self.dicoArg) + + self.monNomClasseModeleMetier='T_'+self.nom + if self.nom in list(self.cata.DicoNomTypeDifferentNomElt.keys()) : + self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.nom][self.nomComplet()] + self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) + + # PN : Ne doit-on pas tester avant + if self.objPyxbDeConstruction != None : + self.objPyxb = self.objPyxbDeConstruction + self.objPyxbDeConstruction = None + #print ('je passe dans le if pour ', self.nom, self.objPyxb, self) + else : + #print (self.nom) + #print (self.listArg) + # self.objPyxb=self.maClasseModeleMetier(*self.listArg) + self.objPyxb=self.maClasseModeleMetier(**self.dicoArg) + newordercontent=[] + for obj in self.listArg: + # on teste le caractere pluriel + if (hasattr(obj, 'nature')) : # attention on a un object Accas et non un pyxb car les MCList n ont pas de objPyxb + max=obj[0].definition.max + else : max = 1 + if max == 1 : + if not(issubclass(type(obj), pyxb.binding.basis.enumeration_mixin) ): + newordercontent.append(self.objPyxb.orderedContent()[map(lambda o:id(o.value), self.objPyxb.orderedContent()).index(id(obj))] ) + else : + newordercontent.append(self.objPyxb.orderedContent()[map(lambda o:type(o.value), self.objPyxb.orderedContent()).index(type(obj))] ) + else : # element Pural + for c in self.objPyxb.orderedContent() : + if isinstance(c._Content__value,list) and isinstance(c._Content__value[0], type(obj[0].objPyxb)): newordercontent.append(c) + + for i in xrange(len(self.listArg)): + self.objPyxb.orderedContent()[i]=newordercontent[i] + self.objPyxb.objAccas=self + #print ('X_MCCOMPO', self, self.nom, self.objPyxb,self.listArg,newordercontent,self.objPyxb.orderedContent()) + #print ('_______________________________________') + # assert(self.objPyxb.validateBinding()) + + + def exploreBLOC(self,objAccas): + #print (' ds exploreBLOC', objAccas .nom) + laListeSsLesBlocs=[] + for fils in objAccas.mcListe: + if fils.nature == 'MCBLOC' : + self.exploreBLOC(fils) + elif fils.nature == 'MCList' : + #print ('exploreBLOC des MCList', fils.nom) + self.dicoArg[fils.nom]=[] + if fils[0].definition.max > 1 : + #print ('ajout de ', fils) + self.listArg.append(fils) # les MCList n ont pas objPyxb + for objFils in fils : + objFils.perePyxb=self + self.dicoArg[fils.nom].append(objFils.objPyxb) + else: + fils[0].perePyxb=self + self.dicoArg[fils.nom]=fils[0].objPyxb + self.listArg.append(fils[0].objPyxb) + else : + if fils.nom == "Consigne" : continue + #print ('ajout de 2', fils.objPyxb) + self.listArg.append(fils.objPyxb) + self.dicoArg[fils.nom]=fils.objPyxb + fils.perePyxb=self + #print (fils.nom ,' est un SIMP a pour pere Pyxb', self, self.nom) + + + + +class X_MCBLOC (X_MCCOMPO): +# -------------------------- + def buildObjPyxb(self,mc_list): + if not self.cata.modeleMetier : return + #print ('X_MCBLOC buildObjPyxb', self.nom, self, mc_list, 'ne fait rien') + self.perePyxb=None + self.objPyxb=None + + def addObjPyxb(self, indiceDsLeContenu): + if not self.cata.modeleMetier : return + print ('X_MCBLOC addObjPyxb', self.nom, self, self.mcListe, indiceDsLeContenu) + rangDeLObjet=indiceDsLeContenu + for obj in self.mcListe: + obj.addObjPyxb( rangDeLObjet) + rangDeLObjet=rangDeLObjet+obj.longueurDsArbre() + + def delObjPyxb(self): + if not self.cata.modeleMetier : return + #print ('X_MCBLOC delObjPyxb', self.nom, ' --------------------------') + for obj in self.mcListe: + obj.delObjPyxb() + #print ('fin X_MCBLOC delObjPyxb --------------------------') + +class X_MCLIST (X_MCCOMPO): +# -------------------------- + + def buildObjPyxb(self,mc_list): + #print ('X_MCLIST buildObjPyxb ne fait rien', self.nom, self, mc_list) + pass + + def addObjPyxb(self,indiceDsLeContenu): + #print ('X_MCLIST addObjPyxb', self.nom, indiceDsLeContenu) + rangDeLObjet=indiceDsLeContenu + for objFils in self : + objFils.addObjPyxb(rangDeLObjet) + rangDeLObjet= rangDeLObjet + 1 + + def delObjPyxb(self): + if not self.cata.modeleMetier : return + #print ('X_MCLIST delObjPyxb', self.nom, ' --------------------------') + for obj in self: + obj.delObjPyxb() + #print ('fin X_MCLIST delObjPyxb --------------------------') + + +class X_MCFACT (X_MCCOMPO): +# ------------------------- + pass + +class X_JDC (X_MCCOMPO): +# --------------------- + + def __init__(self): + self.perePyxb=None + if not self.cata.modeleMetier : return + #if hasattr(self.cata,'DicoNomTypeDifferentNomElt') : print ('jkllllllllllllllll') + if not(hasattr(self.cata,'DicoNomTypeDifferentNomElt')) : self.cata.DicoNomTypeDifferentNomElt={} + 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.NEVER) + pyxb.GlobalValidationConfig._setInvalidElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) + pyxb.GlobalValidationConfig._setOrphanElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) + + + + def enregistreEtapePyxb(self,etape,indice=0): + # ne fonctionne pas : a reecrire avec les fonctions addObjPyxb et ReconstruitPerePyxb + # ne contient pas indice pour l insant + #print ( 'hhhhhhhhhhhhhhh enregistreEtapePyxb hhhhhhhhhhhhhhhhhhhhhhhhh') + #print ('enregistre ds ',self, etape.nom, 'indice = ', indice) + if not self.cata.modeleMetier : return + self.objPyxb.append(etape.objPyxb) + etape.perePyxb = self + + #print (self.objPyxb.orderedContent()) + #if indice != (len(self.objPyxb.orderedContent()) ) : + # 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()) + #try: + # self.objPyxb.validateBinding() + #except pyxb.ValidationError as e: + # print(e.details()) + + def toXml(self,fichier=None): + print ('ds to XML') + if not self.cata.modeleMetier : return + print ('***************',self.objPyxb,'***************',) + print ('***************',self,'***************',) + print ('***************',self.objPyxb.orderedContent(),'***************',) + print(self.objPyxb.toDOM().toprettyxml()) + print(self.objPyxb.toxml()) + return (self.objPyxb.toDOM().toprettyxml()) + + + def analyseFromXML(self): + #print ("je suis ds analyseFromXML -- > appel ds analyse de I_JDC.py") + if self.procedure == "" : return + self.objPyxb=self.cata.modeleMetier.CreateFromDocument(self.procedure) + for objEtape in self.objPyxb.content(): + objEtape.dictArgs= (self.pyxbToDict(objEtape)) + objEtape.monNomClasseAccas=objEtape._ExpandedName.localName() + objEtape.monNomClasseAccas=objEtape.monNomClasseAccas[2:] + objEtape.dictPyxb['objEnPyxb']=objEtape + objEtape.dictArgs['dicoPyxbDeConstruction']=objEtape.dictPyxb + maClasseAccas=getattr(self.cata,objEtape.monNomClasseAccas) + objAccasEtape=maClasseAccas(**(objEtape.dictArgs)) + # attention objAccasEtape = None normal (cf buildSd) + + #print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh') + #print (objEtape , type(objEtape)) + #print (objEtape.dictPyxb) + #print (maClasseAccas) + #print (objAccasEtape) + + #print (objEtape.monNomClasseAccas, type(objEtape.monNomClasseAccas)) + #print (objEtape._ExpandedName, type(objEtape._ExpandedName)) + #print (objEtape.dictPyxb[u'experience']) + #print (objEtape.dictArgs) + #print (objEtape.dictPyxb) + #print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh') + #exit() + + + def pyxbToDict(self,objAAnalyser): + # la transformation de l objAAnalyser en type lu par eficas ne fonctionne pas pour tout + # faudrait - il travailler sur les types des objets ? + # c est a revoir -> fonction cast a prevoir ds les 2 sens + if objAAnalyser is None: return + #print ('debut pour ',objAAnalyser) + dictArgs = {} + if isinstance(objAAnalyser, pyxb.binding.basis.simpleTypeDefinition): + objAAnalyser.dictPyxb=objAAnalyser + #print (objAAnalyser.dictPyxb , type(objAAnalyser.dictPyxb)) + if isinstance(objAAnalyser, pyxb.binding.basis.enumeration_mixin): return str(objAAnalyser) + if isinstance(objAAnalyser, types.StringTypes): return str(objAAnalyser) + if isinstance(objAAnalyser, types.FloatType): return float(objAAnalyser) + if isinstance(objAAnalyser, (types.IntType, types.LongType)): return int(objAAnalyser) + #if isinstance(objAAnalyser, (types.NoneType, types.BooleanType, types.FloatType, types.IntType, types.LongType)): + return repr(objAAnalyser) + # ou ? return objAAnalyser + #if isinstance(objAAnalyser, types.StringTypes): return pyxb.utils.utility.QuotedEscaped(objAAnalyser,) + #pour une enum getattr(value dans le type) + # return pythonLiteral(ReferenceFacet(facet=value, **kw)) + objAAnalyser.dictPyxb = {} + for expandedName, elementDeclaration in objAAnalyser._ElementMap.items(): + objPyxbName = expandedName.localName() + objPyxbValue = getattr(objAAnalyser, objPyxbName) + if objPyxbValue == None or objPyxbValue == [] : continue + if elementDeclaration.isPlural(): + dictArgs[objPyxbName] = [] + #objAAnalyser.dictPyxb[objPyxbName]={} + objAAnalyser.dictPyxb[objPyxbName]=[] + #objAAnalyser.dictPyxb['objEnPyxb']=objAAnalyser + for objPyxb in objPyxbValue : + #print ('-------------',objPyxb) + dictArgs[objPyxbName].append(self.pyxbToDict(objPyxb)) + objPyxb.dictPyxb['objEnPyxb'] = objPyxb + objAAnalyser.dictPyxb[objPyxbName].append(objPyxb.dictPyxb) + else: + dictArgs[objPyxbName] = self.pyxbToDict(getattr(objAAnalyser, objPyxbName)) + #print ('ajout ds dico de ', objAAnalyser , 'de', objPyxbName, objPyxbValue) + objAAnalyser.dictPyxb[objPyxbName] = objPyxbValue.dictPyxb + #print ('ajout ds dico de ', objPyxbValue.dictPyxb, 'de', objPyxbName) + objAAnalyser.dictPyxb['objEnPyxb']=objAAnalyser + #print ("***********************************") + #print ('pyxbToDict fin pour ********** ', objAAnalyser) + #print ('pyxbToDict ', objAAnalyser, objAAnalyser.dictPyxb) + #print ('pyxbToDict fin pour ********** ', objAAnalyser) + #print ("***********************************") + #print (dictArgs) + #print (dictPyxb) + #for i in dictArgs.keys(): print (i, " ", dictArgs[i], " ", type(dictArgs[i])) + #print ('fin pour ',objAAnalyser) + return dictArgs + + +# def analyseContent(self,objAAnalyser): +# objAAnalyser.dictArgs={} +# for objContenu in objAAnalyser.content(): +# #print ('j analyse ', objContenu) +# objContenu.monNomClasseModeleMetier=str(objContenu.__class__).split('.')[-1] +# objContenu.monNomClasseAccas=objContenu.monNomClasseModeleMetier[2:-2] +# #maClasseAccas=classeAccasPere.entites[objContenu.monNomClasseAccas] +# if objContenu._IsSimpleTypeContent(): +# print (objContenu.monNomClasseAccas,objContenu.pythonLiteral()) +# print (objContenu.monNomClasseAccas,objContenu.xsdLiteral()) +# #chaine=objContenu.pythonLiteral().split('(')[1].split(')')[0] +# print (dir(objContenu)) +# objAAnalyser.dictArgs[objContenu.monNomClasseAccas]=None +# #objAAnalyser.dictArgs[objContenu.monNomClasseAccas]=objContenu.pythonLiteral() +# else : +# self.analyseContent(objContenu) +# objAAnalyser.dictArgs[objContenu.monNomClasseAccas]=objContenu.dictArgs + #print ( '________________') + #print (objAAnalyser.monNomClasseAccas) + #for i in objAAnalyser.dictArgs : print (i, objAAnalyser.dictArgs[i]) + #print ( '________________') + + + +if __name__ == "__main__": + print ('a faire') diff --git a/Efi2Xsd/MCAccasXsd.py b/Efi2Xsd/MCAccasXsd.py deleted file mode 100755 index 84c334dd..00000000 --- a/Efi2Xsd/MCAccasXsd.py +++ /dev/null @@ -1,464 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys,os -import inspect -import traceback -def trace(): - traceback.print_stack() -#import raw.efficas as efficas -import types - -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) - -try : - import pyxb - import pyxb.binding - import pyxb.binding.basis - #import pyxb.utils.utility - #import pyxb.utils.domutils -except : pass - -from Accas import A_ASSD - -class X_OBJECT: -# ------------- - - def delObjPyxb(self, debug = False): - if not self.cata.modeleMetier : return - if self.nom == 'Consigne' : return None - trouve = False - - if debug : print self.perePyxb.objPyxb.orderedContent() - if debug : print (map(lambda o:o.value, self.perePyxb.objPyxb.orderedContent())) - - elt=pyxb.binding.basis.ElementContent(self.objPyxb, instance=self.perePyxb.objPyxb, tag=pyxb.namespace.ExpandedName(self.cata.modeleMetier.Namespace, self.nom)) - if debug : print ('element moi = ', elt, 'id de moi = ', id(self.objPyxb)) - if (elt.elementDeclaration.isPlural()): - if debug : print ('je suis Plural') - monIndexInOrderedContent=0 - for c in self.perePyxb.objPyxb.orderedContent(): - if isinstance(c._Content__value,list) and isinstance(c._Content__value[0], type(self.objPyxb)): monIndexInOrderedContent += 1 - - listeObjetsAccas=self.parent.getChild(self.nom,restreint='oui') - if len(listeObjetsAccas) == 1 : monIndex=0 - else : monIndex=listeObjetsAccas.index(self) - - listeObjetsPyxb=getattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key) - listeObjetsPyxb.pop(monIndex) - monIndexInOrderedContent += monIndex - self.perePyxb.objPyxb.orderedContent().pop(monIndexInOrderedContent) - else : - newOrderedContent = [] - for i in self.perePyxb.objPyxb.orderedContent(): - if id(self.objPyxb) == id(i._Content__value) : trouve = True ;continue - newOrderedContent.append(i) - if not trouve : print ('elt a supprimer ', self.nom, 'non trouve') - for i in xrange(len(newOrderedContent)): - self.perePyxb.objPyxb.orderedContent()[i]=newOrderedContent[i] - self.perePyxb.objPyxb.orderedContent().pop(len(newOrderedContent)) - - setattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key,None) - if debug : print (map(lambda o:o.value, self.perePyxb.objPyxb.orderedContent())) - - - - def addObjPyxb(self,indiceDsLeContenu): - if not self.cata.modeleMetier : return - print ('_____________ addObjPyxb ds X_OBJECT', self.nom, indiceDsLeContenu) - # adherence Accas sur le parent - parent=self.parent - while (parent.isBLOC()): - if parent != self.parent : indiceDsLeContenu += parent.rangDsPyxb() - parent=parent.parent - self.perePyxb=parent - - self.objPyxb.objAccas=self - elt=pyxb.binding.basis.ElementContent(self.objPyxb, instance=self.perePyxb.objPyxb, tag=pyxb.namespace.ExpandedName(self.cata.modeleMetier.Namespace, self.nom)) - self.perePyxb.objPyxb.orderedContent().insert(indiceDsLeContenu,elt) - if (elt.elementDeclaration.isPlural()): - # je suis donc un MCList - listeObjetsAccas=self.parent.getChild(self.nom,restreint='oui') - if len(listeObjetsAccas) == 1 : monIndex=1 - else : monIndex=listeObjetsAccas.index(self) - listeObjetsPyxb=getattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key) - listeObjetsPyxb.insert(monIndex,self.objPyxb) - else : - setattr(self.perePyxb.objPyxb,elt.elementDeclaration._ElementDeclaration__key,self.objPyxb) - - def rangDsPyxb(self): - monRangEnAccas=self.parent.mcListe.index(self) - rangEnPyxb=0 - for frere in self.parent.mcListe[0: monRangEnAccas] : - rangEnPyxb += frere.longueurDsArbre() - return rangEnPyxb - - -class X_MCSIMP(X_OBJECT): -# ----------------------- - - def buildObjPyxb(self) : - if not self.cata.modeleMetier : return - if self.nom == 'Consigne' : return None - if self.nom == 'Spring_Stifness' : - #trace() - print ('Sprinf_Stifness' ,self.valeur) - #print ('X_MCSIMP buildObjPyxb', self.nom, self,self.valeur) - #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) - self.objPyxbDeConstruction = None - else : - self.monNomClasseModeleMetier='T_'+self.nom - if self.nom in list(self.cata.DicoNomTypeDifferentNomElt.keys()) : - self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.nom][self.nomComplet()] - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) - - if self.valeur != None : self.objPyxb=self.maClasseModeleMetier(self.valeur) - else : self.objPyxb=self.maClasseModeleMetier(_validate_constraints=False); - - if self.objPyxb !=None : self.objPyxb.objAccas=self - #print ('X_MCSIMP', self.nom, self.objPyxb, ) - #print ('fin X_MCSIMP', self.objPyxb, self.nom, self, self.maClasseModeleMetier,self.valeur) - - - def setValeurObjPyxb(self,newVal): - if not self.cata.modeleMetier : return - print ('dans setValeurObjPyxb MCSIMP ', self.nom, newVal) - #print (' self.perePyxb = ', self.perePyxb.nom) - if inspect.isclass(newVal) and issubclass(newVal,A_ASSD) : newVal = newVal.nom - #print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb) - - if newVal != None : nvlObj=self.maClasseModeleMetier(newVal) - # a priori impossible mais ? - else : nvlObj=self.maClasseModeleMetier(_validate_constraints=False) - self.val=newVal - - setattr(self.perePyxb.objPyxb,self.nom,nvlObj) - trouve=False - indice=0 - for i in self.perePyxb.objPyxb.orderedContent(): - if isinstance(i._Content__value, self.maClasseModeleMetier) : - self.perePyxb.objPyxb.orderedContent()[indice]=self.perePyxb.objPyxb.orderedContent()[-1] - del(self.perePyxb.objPyxb.orderedContent()[-1]) - trouve=True - break - indice+=1 - if not trouve : print ('Attention souci au changement de valeur de ', self.nom) - self.objPyxb=nvlObj - self.objPyxb.objAccas=self - #print ('fin du setValeurObjPyxb pour ', self.nom, self.perePyxb.objPyxb.orderedContent()) - - - - -class X_MCCOMPO(X_OBJECT) : -# ------------------------- -# - def buildObjPyxb(self,mc_list) : - if not self.cata.modeleMetier : return - #print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list) - self.listArg=[] - self.dicoArg={} - for objAccas in mc_list : - if objAccas.nature == 'MCBLOC' : - self.exploreBLOC(objAccas) - elif objAccas.nature == 'MCList' : - if objAccas[0].definition.max > 1 : - self.listArg.append(objAccas) # les MCList n ont pas objPyxb - self.dicoArg[objAccas.nom]=[] - for fils in objAccas : - fils.perePyxb=self - self.dicoArg[objAccas.nom].append(fils.objPyxb) - else : - objAccas[0].perePyxb=self - self.dicoArg[objAccas.nom]=objAccas[0].objPyxb - self.listArg.append(objAccas[0].objPyxb) - else : - if objAccas.nom == 'Consigne' : continue - self.listArg.append(objAccas.objPyxb) - self.dicoArg[objAccas.nom]=objAccas.objPyxb - objAccas.perePyxb=self - - #print('X_MCCOMPO -- listArg ---',self.nom,self.listArg) - #print('X_MCCOMPO -- dicoArg ---',self.nom,self.dicoArg) - - self.monNomClasseModeleMetier='T_'+self.nom - if self.nom in list(self.cata.DicoNomTypeDifferentNomElt.keys()) : - self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.nom][self.nomComplet()] - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier) - - # PN : Ne doit-on pas tester avant - if self.objPyxbDeConstruction != None : - self.objPyxb = self.objPyxbDeConstruction - self.objPyxbDeConstruction = None - #print ('je passe dans le if pour ', self.nom, self.objPyxb, self) - else : - #print (self.nom) - #print (self.listArg) - # self.objPyxb=self.maClasseModeleMetier(*self.listArg) - self.objPyxb=self.maClasseModeleMetier(**self.dicoArg) - newordercontent=[] - for obj in self.listArg: - # on teste le caractere pluriel - if (hasattr(obj, 'nature')) : # attention on a un object Accas et non un pyxb car les MCList n ont pas de objPyxb - max=obj[0].definition.max - else : max = 1 - if max == 1 : - if not(issubclass(type(obj), pyxb.binding.basis.enumeration_mixin) ): - newordercontent.append(self.objPyxb.orderedContent()[map(lambda o:id(o.value), self.objPyxb.orderedContent()).index(id(obj))] ) - else : - newordercontent.append(self.objPyxb.orderedContent()[map(lambda o:type(o.value), self.objPyxb.orderedContent()).index(type(obj))] ) - else : # element Pural - for c in self.objPyxb.orderedContent() : - if isinstance(c._Content__value,list) and isinstance(c._Content__value[0], type(obj[0].objPyxb)): newordercontent.append(c) - - for i in xrange(len(self.listArg)): - self.objPyxb.orderedContent()[i]=newordercontent[i] - self.objPyxb.objAccas=self - #print ('X_MCCOMPO', self, self.nom, self.objPyxb,self.listArg,newordercontent,self.objPyxb.orderedContent()) - #print ('_______________________________________') - # assert(self.objPyxb.validateBinding()) - - - def exploreBLOC(self,objAccas): - #print (' ds exploreBLOC', objAccas .nom) - laListeSsLesBlocs=[] - for fils in objAccas.mcListe: - if fils.nature == 'MCBLOC' : - self.exploreBLOC(fils) - elif fils.nature == 'MCList' : - #print ('exploreBLOC des MCList', fils.nom) - self.dicoArg[fils.nom]=[] - if fils[0].definition.max > 1 : - #print ('ajout de ', fils) - self.listArg.append(fils) # les MCList n ont pas objPyxb - for objFils in fils : - objFils.perePyxb=self - self.dicoArg[fils.nom].append(objFils.objPyxb) - else: - fils[0].perePyxb=self - self.dicoArg[fils.nom]=fils[0].objPyxb - self.listArg.append(fils[0].objPyxb) - else : - if fils.nom == "Consigne" : continue - #print ('ajout de 2', fils.objPyxb) - self.listArg.append(fils.objPyxb) - self.dicoArg[fils.nom]=fils.objPyxb - fils.perePyxb=self - #print (fils.nom ,' est un SIMP a pour pere Pyxb', self, self.nom) - - - - -class X_MCBLOC (X_MCCOMPO): -# -------------------------- - def buildObjPyxb(self,mc_list): - if not self.cata.modeleMetier : return - #print ('X_MCBLOC buildObjPyxb', self.nom, self, mc_list, 'ne fait rien') - self.perePyxb=None - self.objPyxb=None - - def addObjPyxb(self, indiceDsLeContenu): - if not self.cata.modeleMetier : return - print ('X_MCBLOC addObjPyxb', self.nom, self, self.mcListe, indiceDsLeContenu) - rangDeLObjet=indiceDsLeContenu - for obj in self.mcListe: - obj.addObjPyxb( rangDeLObjet) - rangDeLObjet=rangDeLObjet+obj.longueurDsArbre() - - def delObjPyxb(self): - if not self.cata.modeleMetier : return - #print ('X_MCBLOC delObjPyxb', self.nom, ' --------------------------') - for obj in self.mcListe: - obj.delObjPyxb() - #print ('fin X_MCBLOC delObjPyxb --------------------------') - -class X_MCLIST (X_MCCOMPO): -# -------------------------- - - def buildObjPyxb(self,mc_list): - #print ('X_MCLIST buildObjPyxb ne fait rien', self.nom, self, mc_list) - pass - - def addObjPyxb(self,indiceDsLeContenu): - #print ('X_MCLIST addObjPyxb', self.nom, indiceDsLeContenu) - rangDeLObjet=indiceDsLeContenu - for objFils in self : - objFils.addObjPyxb(rangDeLObjet) - rangDeLObjet= rangDeLObjet + 1 - - def delObjPyxb(self): - if not self.cata.modeleMetier : return - #print ('X_MCLIST delObjPyxb', self.nom, ' --------------------------') - for obj in self: - obj.delObjPyxb() - #print ('fin X_MCLIST delObjPyxb --------------------------') - - -class X_MCFACT (X_MCCOMPO): -# ------------------------- - pass - -class X_JDC (X_MCCOMPO): -# --------------------- - - def __init__(self): - self.perePyxb=None - if not self.cata.modeleMetier : return - #if hasattr(self.cata,'DicoNomTypeDifferentNomElt') : print ('jkllllllllllllllll') - if not(hasattr(self.cata,'DicoNomTypeDifferentNomElt')) : self.cata.DicoNomTypeDifferentNomElt={} - 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.NEVER) - pyxb.GlobalValidationConfig._setInvalidElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) - pyxb.GlobalValidationConfig._setOrphanElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION) - - - - def enregistreEtapePyxb(self,etape,indice=0): - # ne fonctionne pas : a reecrire avec les fonctions addObjPyxb et ReconstruitPerePyxb - # ne contient pas indice pour l insant - #print ( 'hhhhhhhhhhhhhhh enregistreEtapePyxb hhhhhhhhhhhhhhhhhhhhhhhhh') - #print ('enregistre ds ',self, etape.nom, 'indice = ', indice) - if not self.cata.modeleMetier : return - self.objPyxb.append(etape.objPyxb) - etape.perePyxb = self - - #print (self.objPyxb.orderedContent()) - #if indice != (len(self.objPyxb.orderedContent()) ) : - # 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()) - #try: - # self.objPyxb.validateBinding() - #except pyxb.ValidationError as e: - # print(e.details()) - - def toXml(self,fichier=None): - print ('ds to XML') - if not self.cata.modeleMetier : return - print ('***************',self.objPyxb,'***************',) - print ('***************',self,'***************',) - print ('***************',self.objPyxb.orderedContent(),'***************',) - print(self.objPyxb.toDOM().toprettyxml()) - print(self.objPyxb.toxml()) - return (self.objPyxb.toDOM().toprettyxml()) - - - def analyseFromXML(self): - #print ("je suis ds analyseFromXML -- > appel ds analyse de I_JDC.py") - if self.procedure == "" : return - self.objPyxb=self.cata.modeleMetier.CreateFromDocument(self.procedure) - for objEtape in self.objPyxb.content(): - objEtape.dictArgs= (self.pyxbToDict(objEtape)) - objEtape.monNomClasseAccas=objEtape._ExpandedName.localName() - objEtape.monNomClasseAccas=objEtape.monNomClasseAccas[2:] - objEtape.dictPyxb['objEnPyxb']=objEtape - objEtape.dictArgs['dicoPyxbDeConstruction']=objEtape.dictPyxb - maClasseAccas=getattr(self.cata,objEtape.monNomClasseAccas) - objAccasEtape=maClasseAccas(**(objEtape.dictArgs)) - # attention objAccasEtape = None normal (cf buildSd) - - #print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh') - #print (objEtape , type(objEtape)) - #print (objEtape.dictPyxb) - #print (maClasseAccas) - #print (objAccasEtape) - - #print (objEtape.monNomClasseAccas, type(objEtape.monNomClasseAccas)) - #print (objEtape._ExpandedName, type(objEtape._ExpandedName)) - #print (objEtape.dictPyxb[u'experience']) - #print (objEtape.dictArgs) - #print (objEtape.dictPyxb) - #print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh') - #exit() - - - def pyxbToDict(self,objAAnalyser): - # la transformation de l objAAnalyser en type lu par eficas ne fonctionne pas pour tout - # faudrait - il travailler sur les types des objets ? - # c est a revoir -> fonction cast a prevoir ds les 2 sens - if objAAnalyser is None: return - #print ('debut pour ',objAAnalyser) - dictArgs = {} - if isinstance(objAAnalyser, pyxb.binding.basis.simpleTypeDefinition): - objAAnalyser.dictPyxb=objAAnalyser - #print (objAAnalyser.dictPyxb , type(objAAnalyser.dictPyxb)) - if isinstance(objAAnalyser, pyxb.binding.basis.enumeration_mixin): return str(objAAnalyser) - if isinstance(objAAnalyser, types.StringTypes): return str(objAAnalyser) - if isinstance(objAAnalyser, types.FloatType): return float(objAAnalyser) - if isinstance(objAAnalyser, (types.IntType, types.LongType)): return int(objAAnalyser) - #if isinstance(objAAnalyser, (types.NoneType, types.BooleanType, types.FloatType, types.IntType, types.LongType)): - return repr(objAAnalyser) - # ou ? return objAAnalyser - #if isinstance(objAAnalyser, types.StringTypes): return pyxb.utils.utility.QuotedEscaped(objAAnalyser,) - #pour une enum getattr(value dans le type) - # return pythonLiteral(ReferenceFacet(facet=value, **kw)) - objAAnalyser.dictPyxb = {} - for expandedName, elementDeclaration in objAAnalyser._ElementMap.items(): - objPyxbName = expandedName.localName() - objPyxbValue = getattr(objAAnalyser, objPyxbName) - if objPyxbValue == None or objPyxbValue == [] : continue - if elementDeclaration.isPlural(): - dictArgs[objPyxbName] = [] - #objAAnalyser.dictPyxb[objPyxbName]={} - objAAnalyser.dictPyxb[objPyxbName]=[] - #objAAnalyser.dictPyxb['objEnPyxb']=objAAnalyser - for objPyxb in objPyxbValue : - #print ('-------------',objPyxb) - dictArgs[objPyxbName].append(self.pyxbToDict(objPyxb)) - objPyxb.dictPyxb['objEnPyxb'] = objPyxb - objAAnalyser.dictPyxb[objPyxbName].append(objPyxb.dictPyxb) - else: - dictArgs[objPyxbName] = self.pyxbToDict(getattr(objAAnalyser, objPyxbName)) - #print ('ajout ds dico de ', objAAnalyser , 'de', objPyxbName, objPyxbValue) - objAAnalyser.dictPyxb[objPyxbName] = objPyxbValue.dictPyxb - #print ('ajout ds dico de ', objPyxbValue.dictPyxb, 'de', objPyxbName) - objAAnalyser.dictPyxb['objEnPyxb']=objAAnalyser - #print ("***********************************") - #print ('pyxbToDict fin pour ********** ', objAAnalyser) - #print ('pyxbToDict ', objAAnalyser, objAAnalyser.dictPyxb) - #print ('pyxbToDict fin pour ********** ', objAAnalyser) - #print ("***********************************") - #print (dictArgs) - #print (dictPyxb) - #for i in dictArgs.keys(): print (i, " ", dictArgs[i], " ", type(dictArgs[i])) - #print ('fin pour ',objAAnalyser) - return dictArgs - - -# def analyseContent(self,objAAnalyser): -# objAAnalyser.dictArgs={} -# for objContenu in objAAnalyser.content(): -# #print ('j analyse ', objContenu) -# objContenu.monNomClasseModeleMetier=str(objContenu.__class__).split('.')[-1] -# objContenu.monNomClasseAccas=objContenu.monNomClasseModeleMetier[2:-2] -# #maClasseAccas=classeAccasPere.entites[objContenu.monNomClasseAccas] -# if objContenu._IsSimpleTypeContent(): -# print (objContenu.monNomClasseAccas,objContenu.pythonLiteral()) -# print (objContenu.monNomClasseAccas,objContenu.xsdLiteral()) -# #chaine=objContenu.pythonLiteral().split('(')[1].split(')')[0] -# print (dir(objContenu)) -# objAAnalyser.dictArgs[objContenu.monNomClasseAccas]=None -# #objAAnalyser.dictArgs[objContenu.monNomClasseAccas]=objContenu.pythonLiteral() -# else : -# self.analyseContent(objContenu) -# objAAnalyser.dictArgs[objContenu.monNomClasseAccas]=objContenu.dictArgs - #print ( '________________') - #print (objAAnalyser.monNomClasseAccas) - #for i in objAAnalyser.dictArgs : print (i, objAAnalyser.dictArgs[i]) - #print ( '________________') - - - -if __name__ == "__main__": - print ('a faire') diff --git a/Efi2Xsd/balises.py b/Efi2Xsd/balises.py deleted file mode 100644 index 1fd572f4..00000000 --- a/Efi2Xsd/balises.py +++ /dev/null @@ -1,62 +0,0 @@ -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' - -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' - -# COMPO -debutTypeCompo = '\t\n' -debutTypeCompoSeq = '\t\t\n' -finTypeCompoSeq = '\t\t\n' -finTypeCompo = '\t\n' -eltCompoDsSequence = '\t\t\t\n' -eltCompoDsSequenceInExtension = '\t\t\t\n' - -# BLOC -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' -#keyRefDeclaration ='\n\t \n\t\t\n\t\t\n\t\n' - -# CATA -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__' : - print ('ne fait rien') - diff --git a/Efi2Xsd/balisesXSD.py b/Efi2Xsd/balisesXSD.py new file mode 100644 index 00000000..1fd572f4 --- /dev/null +++ b/Efi2Xsd/balisesXSD.py @@ -0,0 +1,62 @@ +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' + +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' + +# COMPO +debutTypeCompo = '\t\n' +debutTypeCompoSeq = '\t\t\n' +finTypeCompoSeq = '\t\t\n' +finTypeCompo = '\t\n' +eltCompoDsSequence = '\t\t\t\n' +eltCompoDsSequenceInExtension = '\t\t\t\n' + +# BLOC +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' +#keyRefDeclaration ='\n\t \n\t\t\n\t\t\n\t\n' + +# CATA +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__' : + print ('ne fait rien') + diff --git a/Extensions/param2.py b/Extensions/param2.py index fa5ea0db..cc198709 100644 --- a/Extensions/param2.py +++ b/Extensions/param2.py @@ -25,6 +25,7 @@ try : except : pass import math import types +# PNPN a resorber import six try: diff --git a/Noyau/N_SIMP.py b/Noyau/N_SIMP.py index b7a324f9..ba002dd7 100644 --- a/Noyau/N_SIMP.py +++ b/Noyau/N_SIMP.py @@ -50,7 +50,7 @@ class SIMP(N_ENTITE.ENTITE): def __init__(self, typ,ang="", fr="", statut='f', into=None, intoSug = None,siValide = None, defaut=None, min=1, max=1, homo=1, position='local', val_min=float('-inf'), val_max=float('inf'), docu="", validators=None, nomXML=None, - sug=None,fenetreIhm=None, attribut=False, creeDesObjetsDeType = None, sortie='n'): + sug=None,fenetreIhm=None, attribut=False, sortie='n'): """ Un mot-clé simple est caractérisé par les attributs suivants : - type : cet attribut est obligatoire et indique le type de valeur attendue @@ -81,40 +81,48 @@ class SIMP(N_ENTITE.ENTITE): N_ENTITE.ENTITE.__init__(self, validators) # Initialisation des attributs self.creeDesObjets = False + self.utiliseUneReference = False + self.creeDesObjetsDeType = None + self.utiliseDesObjetsDeType = None if type(typ) == tuple: self.type = typ else: self.type = (typ,) for t in (self.type) : try : - if issubclass(t,Accas.UserASSD) : creeDesObjetsDeType = t + if issubclass(t,Accas.UserASSD) : + creeDesObjetsDeType = t + self.utiliseUneReference = True except : pass if t == 'createObject' : self.creeDesObjets=True - self.fr = fr - self.statut = statut - self.into = into - self.intoSug = intoSug + if self.utiliseUneReference : + if self.creeDesObjets : + self.utiliseUneReference = False + self.creeDesObjetsDeType = creeDesObjetsDeType + else : self.utiliseDesObjetsDeType = creeDesObjetsDeType + self.fr = fr + self.statut = statut + self.into = into + self.intoSug = intoSug self.siValide = siValide - self.defaut = defaut - self.min = min - self.max = max - self.homo = homo + self.defaut = defaut + self.min = min + self.max = max + self.homo = homo self.position = position - self.val_min = val_min - self.val_max = val_max - self.docu = docu - self.sug = sug - self.ang=ang + self.val_min = val_min + self.val_max = val_max + self.docu = docu + self.sug = sug + self.ang = ang if self.max == '**' : self.max = float('inf') if self.val_max == '**' : self.val_max = float('inf') if self.min == '**' : self.min = float('-inf') if self.val_min == '**' : self.val_min = float('-inf') - self.fenetreIhm=fenetreIhm - self.attribut = attribut - if self.creeDesObjets : self.creeDesObjetsDeType = creeDesObjetsDeType - else : self.creeDesObjetsDeType = None - self.nomXML = nomXML - self.sortie=sortie + self.fenetreIhm = fenetreIhm + self.attribut = attribut + self.nomXML = nomXML + self.sortie = sortie def verifCata(self): """