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={}):
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
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,
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):
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):
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):
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):
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,
PourTraduction = False
-from .balises import *
+from .balisesXSD import *
# -----------------
class X_definition:
# -----------------
--- /dev/null
+#!/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')
+++ /dev/null
-#!/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')
+++ /dev/null
-texteDebut='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/Vimmp"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
-texteFin='</xs:schema>'
-texteDebutCataSpecifique='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:VimmpSpec="http://chercheurs.edf.com/logiciels/VimmpSpec" xmlns="http://chercheurs.edf.com/logiciels/VimmpSpec" targetNamespace="http://chercheurs.edf.com/logiciels/VimmpSpec" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0">'
-
-# SIMP
-
-
-debutSimpleType = '\t<xs:simpleType name="{}">\n'
-fermeSimpleType = '\t</xs:simpleType>\n'
-debutRestrictionBase = '\t\t<xs:restriction base="{}">\n'
-fermeRestrictionBase = '\t\t</xs:restriction>\n'
-enumeration = '\t\t\t<xs:enumeration value="{}"/>\n'
-maxInclusiveBorne = '\t\t\t<xs:maxInclusive value = "{}"/>\n'
-minInclusiveBorne = '\t\t\t<xs:minInclusive value = "{}"/>\n'
-
-debutTypeSimpleListe = '\t\t<xs:restriction>\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:list>\n\t\t\t\t\t<xs:simpleType>\n'
-finTypeSimpleListe = '\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t\t\t</xs:simpleType>\n'
-fermeBalisesMileu = '\t\t\t\t\t\t</xs:restriction>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t </xs:simpleType>\n'
-
-maxLengthTypeSimple = '\t\t\t<xs:maxLength value = "{}"/>\n'
-minLengthTypeSimple = '\t\t\t<xs:minLength value = "{}"/>\n'
-eltDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
-eltWithDefautDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}" default="{}"/>\n'
-
-# COMPO
-debutTypeCompo = '\t<xs:complexType name="{}" >\n'
-debutTypeCompoSeq = '\t\t<xs:sequence>\n'
-finTypeCompoSeq = '\t\t</xs:sequence>\n'
-finTypeCompo = '\t</xs:complexType>\n'
-eltCompoDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
-eltCompoDsSequenceInExtension = '\t\t\t<xs:element name="{}" type="{}:{}"/>\n'
-
-# BLOC
-debutTypeSubst = '\t<xs:group name="{}"> \n\t\t<xs:sequence>\n'
-finTypeSubst = '\t\t</xs:sequence>\n\t</xs:group>\n'
-substDsSequence = '\t\t\t<xs:group ref="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
-
-
-# User OR ASSD
-
-operAttributeName = '\t\t<xs:attribute name="nom" type="xs:string"/>\n'
-attributeTypeForASSD = '\t\t<xs:attribute name="acassType" type="xs:string" fixed="ASSD"/>\n'
-attributeTypeUtilisateurName = '\t\t<xs:attribute name="typeUtilisateur" type="xs:string" fixed="{}"/>\n'
-#keyRefDeclaration ='\n\t<xs:keyref name="{}_Name_ref" refer="Key_Name_In_{}"> \n\t\t<xs:selector xpath="{}:{}_Name"/>\n\t\t<xs:field xpath="."/>\n\t</xs:keyref>\n'
-
-# CATA
-debutTypeCata = '\t<xs:complexType name="{}">\n\t\t<xs:choice minOccurs="0" maxOccurs="unbounded">\n'
-finTypeCata = '\t\t</xs:choice>\n\t</xs:complexType>\n'
-finSchema = '</xs:schema>'
-eltCata = '\t<xs:element name="{}" type="{}:{}"/>\n'
-TypeEtEltAbstraitCodeSpec = '\t<xs:complexType name="T_Code_Specific" abstract="true"/>\n\t<xs:element name="Code_Specific" type="{}:T_Code_Specific"/>\n'
-EltCodeSpecDsCata='\t\t\t<xs:element ref="{}:Code_Specific" minOccurs="0" maxOccurs="1"/>\n'
-includeCata = '\t<xs:include schemaLocation="cata_{}_genere.xsd" />\n\n'
-
-# EXTENSION
-debutEtension = '\t\t<xs:complexContent>\n\t\t<xs:extension base="{}:T_Code_Specific">\n'
-finExtension = '\t\t</xs:extension>\n\t\t</xs:complexContent>\n'
-
-
-if __name__ == '__main__' :
- print ('ne fait rien')
-
--- /dev/null
+texteDebut='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/Vimmp"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
+texteFin='</xs:schema>'
+texteDebutCataSpecifique='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:VimmpSpec="http://chercheurs.edf.com/logiciels/VimmpSpec" xmlns="http://chercheurs.edf.com/logiciels/VimmpSpec" targetNamespace="http://chercheurs.edf.com/logiciels/VimmpSpec" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0">'
+
+# SIMP
+
+
+debutSimpleType = '\t<xs:simpleType name="{}">\n'
+fermeSimpleType = '\t</xs:simpleType>\n'
+debutRestrictionBase = '\t\t<xs:restriction base="{}">\n'
+fermeRestrictionBase = '\t\t</xs:restriction>\n'
+enumeration = '\t\t\t<xs:enumeration value="{}"/>\n'
+maxInclusiveBorne = '\t\t\t<xs:maxInclusive value = "{}"/>\n'
+minInclusiveBorne = '\t\t\t<xs:minInclusive value = "{}"/>\n'
+
+debutTypeSimpleListe = '\t\t<xs:restriction>\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:list>\n\t\t\t\t\t<xs:simpleType>\n'
+finTypeSimpleListe = '\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t\t\t</xs:simpleType>\n'
+fermeBalisesMileu = '\t\t\t\t\t\t</xs:restriction>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t </xs:simpleType>\n'
+
+maxLengthTypeSimple = '\t\t\t<xs:maxLength value = "{}"/>\n'
+minLengthTypeSimple = '\t\t\t<xs:minLength value = "{}"/>\n'
+eltDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+eltWithDefautDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}" default="{}"/>\n'
+
+# COMPO
+debutTypeCompo = '\t<xs:complexType name="{}" >\n'
+debutTypeCompoSeq = '\t\t<xs:sequence>\n'
+finTypeCompoSeq = '\t\t</xs:sequence>\n'
+finTypeCompo = '\t</xs:complexType>\n'
+eltCompoDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+eltCompoDsSequenceInExtension = '\t\t\t<xs:element name="{}" type="{}:{}"/>\n'
+
+# BLOC
+debutTypeSubst = '\t<xs:group name="{}"> \n\t\t<xs:sequence>\n'
+finTypeSubst = '\t\t</xs:sequence>\n\t</xs:group>\n'
+substDsSequence = '\t\t\t<xs:group ref="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+
+
+# User OR ASSD
+
+operAttributeName = '\t\t<xs:attribute name="nom" type="xs:string"/>\n'
+attributeTypeForASSD = '\t\t<xs:attribute name="acassType" type="xs:string" fixed="ASSD"/>\n'
+attributeTypeUtilisateurName = '\t\t<xs:attribute name="typeUtilisateur" type="xs:string" fixed="{}"/>\n'
+#keyRefDeclaration ='\n\t<xs:keyref name="{}_Name_ref" refer="Key_Name_In_{}"> \n\t\t<xs:selector xpath="{}:{}_Name"/>\n\t\t<xs:field xpath="."/>\n\t</xs:keyref>\n'
+
+# CATA
+debutTypeCata = '\t<xs:complexType name="{}">\n\t\t<xs:choice minOccurs="0" maxOccurs="unbounded">\n'
+finTypeCata = '\t\t</xs:choice>\n\t</xs:complexType>\n'
+finSchema = '</xs:schema>'
+eltCata = '\t<xs:element name="{}" type="{}:{}"/>\n'
+TypeEtEltAbstraitCodeSpec = '\t<xs:complexType name="T_Code_Specific" abstract="true"/>\n\t<xs:element name="Code_Specific" type="{}:T_Code_Specific"/>\n'
+EltCodeSpecDsCata='\t\t\t<xs:element ref="{}:Code_Specific" minOccurs="0" maxOccurs="1"/>\n'
+includeCata = '\t<xs:include schemaLocation="cata_{}_genere.xsd" />\n\n'
+
+# EXTENSION
+debutEtension = '\t\t<xs:complexContent>\n\t\t<xs:extension base="{}:T_Code_Specific">\n'
+finExtension = '\t\t</xs:extension>\n\t\t</xs:complexContent>\n'
+
+
+if __name__ == '__main__' :
+ print ('ne fait rien')
+
except : pass
import math
import types
+# PNPN a resorber
import six
try:
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
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):
"""