self.ordre_mc=[]
self.lesConditions = 'Possible Conditions : '
for mc in listeDeCreation :
- self.lesConditions += '\n\t\t\t\t\t\t' + mc.condition
+ if hasattr(mc, 'condition'):self.lesConditions += '\n\t\t\t\t\t\t' + mc.condition
self.mcXSD.append(mc)
self.ordre_mc.append(mc.nom)
class X_SIMP (X_definition):
#--------------------------------
def dumpXsd(self, dansFactorisation=False, multiple=False, first=False, debug=False):
- debug = True
+ #debug = True
#if PourTraduction : print (self.nom)
if debug : print ('X_SIMP dumpXsd pour', self.nom, '___________________________')
self.prepareDumpXSD()
self.dumpSpecifiqueMatrice(minOccurs)
return
+ if self.suisUnTuple :
+ self.dumpSpecifiqueTuple(minOccurs)
+ return
+
#print ('minOccurs',minOccurs)
# le defaut est dans l elt Name -> tester la coherence d existence avec Accas
# regles Accas
if not('TXM' in (self.type)) : separe = ' '
else : separe ='\n'
for val in self.defaut : txtDefaut+=str(val) + separe
+ # cela ne fonctionne pas tres bien. a revoir
txtDefaut+=txtDefaut[0:-1]
if not('TXM' in (self.type)) :
# a revoir pour les tuples avec defaut
else :
if str(self.defaut) == 'True' : txtDefaut = 'true'
elif str(self.defaut) == 'False' : txtDefaut = 'false'
- else : txtDefaut = str(self.defaut)+('\n')
+ else : txtDefaut = str(self.defaut)
if texteAide != '' : self.texteElt = eltDsSequenceWithDefautAndHelp.format(self.nom,self.code,self.nomDuTypePyxb,minOccurs,1,txtDefaut,texteAide)
else : self.texteElt = eltDsSequenceWithDefaut.format(self.nom,self.code,self.nomDuTypePyxb,minOccurs,1,txtDefaut)
else :
self.texteSimple = self.texteSimplePart1 + self.texteSimplePart2
+ def dumpSpecifiqueTuple(self,minOccurs):
+ self.nomDuTypeDeBase = self.traduitType()
+ tousPareil=True
+ # il faut gerer l aide et les defaut
+ if self.defaut : print ('il faut tester le defaut')
+ if self.max == '**' or self.max == float('inf') : max='unbounded'
+ else : max = self.max
+ self.texteElt = tupleNonHomogeneElt.format(self.nom,self.code,self.nomDuTypePyxb,minOccurs,max)
+ leType=self.nomDuTypeDeBase[0]
+ for leTypeComp in self.nomDuTypeDeBase[1:] :
+ if leTypeComp != leType :
+ tousPareil = False
+ break;
+ #if tousPareil :
+ #PN PN a statuer
+ # self.texteSimple += debutSimpleType.format(self.nomDuTypePyxb)
+ # self.texteSimple += debutTypeSimpleListe
+ # self.texteSimple += "\t\t\t\t"+debutRestrictionBase.format(leType)
+ # if self.val_min != float('-inf') : self.texteSimple += "\t\t\t\t"+minInclusiveBorne.format(self.val_min)
+ # if self.val_max != float('inf') and self.val_max != '**' : self.texteSimple +="\t\t\t\t"+ maxInclusiveBorne.format(self.val_max)
+ # if self.into != None:
+ # into=self.into
+ # if self.intoXML != None : into = self.intoXML
+ # for val in into : self.texteSimple += "\t\t\t\t"+enumeration.format(val)
+ # if PourTraduction :
+ # for val in into : print (str(val))
+ # self.texteSimple += fermeBalisesMileu
+ # if self.max !=1 and self.max != '**' and self.max != float('inf') : self.texteSimple += maxLengthTypeSimple.format(self.max)
+ # if self.min !=1 and self.min != float('-inf') : self.texteSimple += minLengthTypeSimple.format(self.min)
+ # self.texteSimple += fermeSimpleType
+ # return
+
+ self.texteSimple = ''
+ complexeTypeTuple = tupleDebutComplexeType.format(self.nomDuTypePyxb)
+ num = 1
+ for leType in self.nomDuTypeDeBase :
+ self.texteSimple += tupleNonHomogeneSimpleType.format(self.nomDuTypePyxb,str(num),leType)
+ complexeTypeTuple += tupleMilieuComplexeType.format(str(num),self.nomDuTypePyxb,str(num))
+ num = num + 1
+ complexeTypeTuple += tupleFinComplexeType
+ self.texteSimple += complexeTypeTuple
+
+
def dumpSpecifiqueMatrice(self,minOccurs):
# if faut traiter le defaut
typeDeMatrice =self.type[0]
nom=self.nomDuTypePyxb
nbCols=typeDeMatrice.nbCols
nbLigs=typeDeMatrice.nbCols
- self.texteSimple += matriceSimpleType.format(nom,nom,nbCols,nom,self.nom,self.code,nom,nbLigs,nbLigs,nom,self.code,nom,self.min,self.max)
- self.texteElt = "\t\t\t\t"+eltMatrice.format(self.code,nom,minOccurs,1)+"\n"
+ self.texteSimple += matriceSimpleType.format(nom,nom,nbCols,nom,self.code,nom,nbLigs,nbLigs,nom,self.code,nom,self.min,self.max)
+ self.texteElt = eltMatrice.format(self.nom,self.code,self.nomDuTypePyxb,minOccurs,1)
def prepareDumpXSD(self):
# il faut gerer les types tuple et fichier
# on ne paut pas tester le type qui depend du cataloge
if hasattr(self.type[0], 'typElt') :
- #print ('je suis une Matrice de ' ,dictNomsDesTypes[self.type[0].typElt])
- self.suisUneMatrice = True
- return dictNomsDesTypes[self.type[0].typElt]
+ #print ('je suis une Matrice de ' ,dictNomsDesTypes[self.type[0].typElt])
+ self.suisUneMatrice = True
+ return dictNomsDesTypes[self.type[0].typElt]
else :
- self.suisUneMatrice = False
+ self.suisUneMatrice = False
if hasattr(self.type[0], 'ntuple') :
- try :
- leType=self.validators.typeDesTuples[0]
- for i in range(self.type[0].ntuple):
- if self.validators.typeDesTuples[i] != leType : return ('XXXXXXXX')
- typeATraduire=leType
- except :
- return ('XXXXXXXX')
+ self.suisUnTuple = True
+ # Pour l instant pas de into dans les tuples non homogenes et pas de reference
+ # sinon, il faudra faire un for sur la suite avec les createObjet
+ leType=self.validators.typeDesTuples[0]
+ enRetour=[]
+ for i in range(self.type[0].ntuple):
+ enRetour.append(dictNomsDesTypes[self.validators.typeDesTuples[i]])
+ return enRetour
+ #typeATraduire=leType
else :
+ self.suisUnTuple = False
typeATraduire=self.type[0]
if not (typeATraduire in list(dictNomsDesTypes.keys())) :
#if (isinstance(typeATraduire, Accas.ASSD) or issubclass(typeATraduire, Accas.ASSD)) :
if self.objPyxbDeConstruction != None :
self.objPyxb = self.objPyxbDeConstruction
- #self.objPyxb.objAccas=self
self.maClasseModeleMetier =type(self.objPyxb)
self.objPyxbDeConstruction = None
if issubclass(self.maClasseModeleMetier, self.cata.modeleMetier.pyxb.binding.basis.STD_union):
self.monNomClasseModeleMetier=self.cata.DicoNomTypeDifferentNomElt[self.monNomClasseModeleMetier][nomComplet]
if debug : print ('Pour', self.nom, ' le type est ', self.monNomClasseModeleMetier)
self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier)
+
+ if self.waitMatrice() :
+ #PNPN : Attention rien ne relie la listeObjPyxb et l objAccas
+ # 21/04 je ne sais pas si cela posera pb
+ debug = 1
+ self.objPyxb = []
+ self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier)
+ if debug : print ('Matrice de type ', self.maClasseModeleMetier)
+ #for v in self.valeur: self.objPyxb.append(self.maClasseModeleMetier(v))
+ for v in self.valeur:
+ l=self.maClasseModeleMetier(v)
+ l.objAccas=self
+ self.objPyxb.append(l)
+ if debug : print ('Matrice ', self.nom, self.objPyxb)
+ return
if issubclass(self.maClasseModeleMetier, self.cata.modeleMetier.pyxb.binding.basis.STD_union):
if debug : print ('needFactory')
self.needFactory=True
def buildObjPyxb(self,mc_list, debug=False) :
if not self.cata or not self.cata.modeleMetier : return
+ debug=1
if debug : print ('X_MCCOMPO', self.nom)
self.listArg=[]
self.dicoArg={}
self.listArg.append(objAccas[0].objPyxb)
else :
if objAccas.nom == 'Consigne' : continue
- self.listArg.append(objAccas.objPyxb)
+ if 0 : #objAccas.waitMatrice() :
+ for o in objAccas.objPyxb : self.listArg.append(o)
+ else: self.listArg.append(objAccas.objPyxb)
self.dicoArg[objAccas.nom]=objAccas.objPyxb
objAccas.perePyxb=self
# self.objPyxb=self.maClasseModeleMetier(*self.listArg)
self.objPyxb=self.maClasseModeleMetier(**self.dicoArg)
if debug :
+ print ('debut de __________ new ordered content')
for o in self.objPyxb.orderedContent():
print ('o', o)
print ('value', o.value)
print ('type', type(o.value))
print ('id', id(o.value))
- print ('fin __________ ordered content')
+ print ('fin __________ new ordered content')
+ print ('debut de __________ listArg')
+ for obj in self.listArg:
+ print ('obj',obj)
+ print ('type obj', type(obj))
+ print ('id(obj)', id(obj))
+ print ('fin __________ listArg')
+
newOrderedContent=[]
if debug : print ('list Arg')
for obj in self.listArg:
print ('id(obj)', id(obj))
# on teste le caractere pluriel
+ if isinstance(obj, list):
+ for c in self.objPyxb.orderedContent() :
+ if hasattr (c,'value') and c.value == obj :
+ newOrderedContent.append(c)
+ continue
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
for i in range(len(self.listArg)):
self.objPyxb.orderedContent()[i]=newOrderedContent[i]
if debug : print ('X_MCCOMPO', self, self.nom, self.objPyxb,self.listArg,newOrderedContent,self.objPyxb.orderedContent())
- #self.objPyxb.objAccas=self
if debug : print ('fin buildObjetPyxb _______________________________________')
# assert(self.objPyxb.validateBinding())
#\n\t<xs:element name="{}_Abstract" type="{}:T_{}_Abstract"/>\n'
#implementeAbstrait = '\t<xs:element name="{}" type="{}:{}" substitutionGroup="{}:{}_Abstract"/>\n'
+# MATRICE oldVersion
+# (_matrix ou pas ?)
+#matriceSimpleType = '\t<xs:simpleType name="{}_matrix">\n\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\t\t\t\t\t\t<xs:restriction base="{}_element"/>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t</xs:simpleType>\n\t\t\t<xs:length value="{}"/>\n\t\t</xs:restriction>\n\t</xs:simpleType>\n'
+#matriceSimpleType = '\t<xs:simpleType name="{}">\n\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\t\t\t\t\t\t<xs:restriction base="{}_element"/>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t</xs:simpleType>\n\t\t\t<xs:length value="{}"/>\n\t\t</xs:restriction>\n\t</xs:simpleType>\n'
+#matriceSimpleType +='\t<xs:group name="{}_lines">\n\t\t<xs:sequence>\n\t\t\t<xs:element name="{}" type="{}:{}_matrix" minOccurs="{}" maxOccurs="{}"/>\t\n\t\t</xs:sequence>\n\t</xs:group>\n\t\n'
+#matriceSimpleType +='\t<xs:group name="{}_lines">\n\t\t<xs:sequence>\n\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\t\n\t\t</xs:sequence>\n\t</xs:group>\n\t\n'
+#matriceSimpleType +='\t<xs:group name="{}_content">\n\t\t<xs:sequence>\n\t\t\t<xs:group ref="{}:{}_lines" minOccurs="1" maxOccurs="1"/>\t\n\t\t</xs:sequence>\n\t</xs:group>'
+#eltMatrice = ' <xs:group ref="{}:{}_content" minOccurs="{}" maxOccurs="{}"/>'
+
+# TUPLE
+tupleNonHomogeneSimpleType = '\t<xs:simpleType name="{}_n{}">\n\t\t<xs:restriction base="{}"/>\n\t\t</xs:simpleType>\n'
+tupleNonHomogeneElt = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+tupleDebutComplexeType = '\t<xs:complexType name="{}">\n\t\t<xs:sequence>'
+tupleMilieuComplexeType = '\n\t\t\t<xs:element name="n{}" type="{}_n{}" minOccurs="1" maxOccurs="1"/>'
+tupleFinComplexeType = '\n\t\t</xs:sequence>\n\t</xs:complexType>\n'
+
# MATRICE
-matriceSimpleType = '\t<xs:simpleType name="{}_matrix">\n\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\t\t\t\t\t\t<xs:restriction base="{}_element"/>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t</xs:simpleType>\n\t\t\t<xs:length value="{}"/>\n\t\t</xs:restriction>\n\t</xs:simpleType>\n'
-matriceSimpleType +='\t<xs:group name="{}_lines">\n\t\t<xs:sequence>\n\t\t\t<xs:element name="{}" type="{}:{}_matrix" minOccurs="{}" maxOccurs="{}"/>\t\n\t\t</xs:sequence>\n\t</xs:group>\n\t\n'
-matriceSimpleType +='\t<xs:group name="{}_content">\n\t\t<xs:sequence>\n\t\t\t<xs:group ref="{}:{}_lines" minOccurs="1" maxOccurs="1"/>\t\n\t\t</xs:sequence>\n\t</xs:group>'
-eltMatrice = ' <xs:group ref="{}:{}_content" minOccurs="{}" maxOccurs="{}"/>'
+eltMatrice = '\t\t\t <xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+matriceSimpleType = '\t<xs:simpleType name="{}_line">\n\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\t\t\t\t\t\t<xs:restriction base="{}_element"/>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t</xs:simpleType>\n\t\t\t<xs:length value="{}"/>\n\t\t</xs:restriction>\n\t</xs:simpleType>\n'
+matriceSimpleType +='\t<xs:group name="{}_matrix">\n\t\t<xs:sequence>\n\t\t\t<xs:element name="line" type="{}:{}_line" minOccurs="{}" maxOccurs="{}"/>\n\t\t </xs:sequence>\n\t</xs:group>\n'
+matriceSimpleType +='\t<xs:complexType name="{}"> \n\t\t<xs:group ref="{}:{}_matrix" minOccurs="1" maxOccurs="1"/>\n\t</xs:complexType>\n'
if __name__ == '__main__' :
print ('ne fait rien')