Salome HOME
XSD des cata multiples + bug validator sur les tuples en python3
authorpascale.noyret <pascale.noyret@edf.fr>
Tue, 28 Apr 2020 13:31:34 +0000 (15:31 +0200)
committerpascale.noyret <pascale.noyret@edf.fr>
Tue, 28 Apr 2020 13:31:34 +0000 (15:31 +0200)
Accas/A_TUPLE.py
Efi2Xsd/AccasXsd.py
Efi2Xsd/balisesXSD.py
InterfaceQT4/readercata.py
Noyau/N_VALIDATOR.py

index 0e9549c1e44901ba002b4c235fe086d22a1f1f06..4cbd14e3c11155f88499683b0cc365db75add423 100644 (file)
@@ -4,7 +4,10 @@ class Tuple:
     self.ntuple=ntuple
 
   def __convert__(self,valeur):
-    if type(valeur) == types.StringType: return None
+    try:
+       if isinstance(valeur, basestring) : return None
+    except NameError:
+       if isinstance(valeur, str): return None
     if len(valeur) != self.ntuple: return None
     return valeur
 
index ef07f26f290f202dd5e4a1d4506ece12816cb1eb..4ae11cc0fe65196c311a5dbb2b3d5e8452f4d4c2 100755 (executable)
@@ -447,7 +447,7 @@ class X_definitionComposee (X_definition):
        return texteComplexeVenantDesFils
 
    def dumpXsd(self,dansFactorisation=False):
-       #print ('_________ dumpXsd___________', self.nom)
+       print ('_________ dumpXsd___________', self.nom)
        if PourTraduction  : print (self.nom)
        self.prepareDumpXSD()
  
@@ -460,12 +460,15 @@ class X_definitionComposee (X_definition):
        # 
        if self.aCreer :
           self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb)
+          if isinstance(self,X_OPER) or isinstance(self,X_PROC) : 
+            self.texteComplexe += debutTypeCompoEtape.format(self.code)
           self.texteComplexe += debutTypeCompoSeq
           texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils(dansFactorisation)
           self.texteComplexe  = texteComplexeVenantDesFils + self.texteComplexe
-          if not isinstance(self,X_OPER ) : 
-             self.texteComplexe += finTypeCompoSeq
-             self.texteComplexe += finTypeCompo
+          # la fin de l oper est traitee dans le dumpXSD de X_OPER
+          if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompoSeq
+          if isinstance(self,X_PROC)      : self.texteComplexe += finTypeCompoEtape
+          if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompo
        else :
           self.texteComplexe = ""
 
@@ -639,6 +642,7 @@ class X_OPER (X_definitionComposee):
        self.texteComplexe += operAttributeName
        self.texteComplexe += attributeTypeForASSD
        self.texteComplexe += attributeTypeUtilisateurName.format(self.sd_prod.__name__)
+       self.texteComplexe += finTypeCompoEtape
        self.texteComplexe += finTypeCompo
 
 
@@ -890,53 +894,77 @@ class X_SIMP (X_definition):
 class X_JDC_CATA :
 #-----------------
 
-    def dumpXsd(self):
+    def dumpXsd(self, debug = True):
         cata = CONTEXT.getCurrentCata() 
 
-        #print ('self.implement  -------------------', self.implement)
-        #print ('self.importedBy -------------------', self.importedBy)
-        #print ('self.code       -------------------', self.code)
+        if debug : print ('self.importedBy -------------------', self.importedBy)
+        if debug : print ('self.code       -------------------', self.code)
 
         self.texteSimple   = ""
         self.texteComplexe = ""
         self.texteCata     = ""  
-        self.texteDeclaration = ""
-        self.texteInclusion   = ""
-        self.texteElt      = ""
+        self.texteDeclaration  = ""
+        self.texteInclusion    = ""
+        self.texteElt          = ""
+        self.texteTypeAbstrait = ""
 
         if self.implement == "" :
-           self.nomDuCodeDumpe=self.code
-           self.texteCata    += debutTypeCata.format(self.nomDuCodeDumpe)
+           self.nomDuCodeDumpe = self.code
+           self.implement      = self.code
+           self.nomDuXsdPere   = self.code
         else :
-           self.implement,self.nomDuXsdInclus=self.implement.split(':')
+           self.implement,self.nomDuXsdPere=self.implement.split(':')
            self.nomDuCodeDumpe = self.implement
-           self.texteCata      +=  debutTypeCataExtension.format(self.nomDuCodeDumpe)
-           self.texteCata      +=  debutExtension.format(self.code,self.nomDuCodeDumpe)
-           self.texteInclusion += includeCata.format(self.nomDuXsdInclus)
 
-        self.nomDuTypePyxb = 'T_'+self.nomDuCodeDumpe
+        if debug : print ('self.implement       -------------------', self.implement)
+        if debug : print ('self.nomDuCodeDumpe   -------------------', self.implement)
+        if debug : print ('self.nomDuXsdPere  -------------------', self.nomDuXsdPere)
+
+        self.nomDuTypePyxb    = 'T_'+self.nomDuCodeDumpe
         self.dumpLesCommandes()
 
-        self.texteTypeAbstrait=''
-        for codeHeritant in self.importedBy: 
-            self.texteCata += eltCodeSpecDsCata.format(codeHeritant)
-            self.texteTypeAbstrait += eltAbstrait.format(codeHeritant,codeHeritant,self.code,codeHeritant)
+        if self.implement == self.code :
+           self.texteCata += eltAbstraitCataPPal.format(self.code)
+        else :
+           self.texteCata += eltAbstraitCataFils.format(self.implement,self.nomDuXsdPere,self.nomDuXsdPere)
+           self.texteInclusion += includeCata.format(self.nomDuXsdPere)
 
-        if self.implement != "" : self.texteCata = self.texteCata + finExtension + finTypeCompo
-        else : self.texteCata  += finTypeCata
+        self.texteCata += eltCata.format(self.implement,self.implement,self.implement,self.implement,self.nomDuXsdPere)
+        #if self.implement == self.code :
+        #   self.texteCata      += debutTypeCata.format(self.nomDuCodeDumpe)
+        #else :
+        #   self.texteCata      += debutTypeCataExtension.format(self.nomDuCodeDumpe)
+        #   self.texteCata      += debutExtension.format(self.code,self.nomDuCodeDumpe)
+        #   self.texteInclusion += includeCata.format(self.nomDuXsdPere)
 
-        if self.implement != "" :
-           self.texteElt=implementeAbstrait.format(self.nomDuCodeDumpe,self.code,self.nomDuTypePyxb,self.code,self.nomDuCodeDumpe)
-        else :
-           self.texteElt  = eltCata.format(self.nomDuCodeDumpe,self.code, self.nomDuTypePyxb)
 
-        self.texteXSD  = texteDebut.format(self.code,self.code,self.code,self.code)
+
+        #for codeHeritant in self.importedBy: 
+        #    self.texteCata += eltCodeSpecDsCata.format(codeHeritant)
+        #    self.texteTypeAbstrait += eltAbstrait.format(codeHeritant,codeHeritant,self.code,codeHeritant)
+
+        #if self.implement != "" : self.texteCata = self.texteCata + finExtension + finTypeCompo
+        #else : self.texteCata  += finTypeCata
+
+        #if self.implement != "" :
+        #   self.texteElt=implementeAbstrait.format(self.nomDuCodeDumpe,self.code,self.nomDuTypePyxb,self.code,self.nomDuCodeDumpe)
+        #else :
+        #   self.texteElt  = eltCata.format(self.nomDuCodeDumpe,self.code, self.nomDuTypePyxb)
+
+        if self.implement == self.code :
+           self.texteXSD  = texteDebut.format(self.code,self.code,self.code,self.code,self.code,self.code)
+        elif self.nomDuXsdPere ==  self.code :
+           self.texteXSD  = texteDebutNiveau2.format(self.code,self.implement,self.code,self.code,self.code, self.code,self.code,self.code,self.code,self.code)
+        else : 
+           self.texteXSD  = texteDebutNiveau3.format(self.code,self.implement,self.code,self.nomDuXsdPere,self.code,self.code,self.code, self.code,self.code,self.code,self.code,self.code)
+
         if self.texteInclusion != ""   : self.texteXSD += self.texteInclusion
         self.texteXSD += self.texteSimple
         self.texteXSD += self.texteComplexe
-        if self.texteTypeAbstrait != "" : self.texteXSD += self.texteTypeAbstrait
+
+        #if self.texteTypeAbstrait != "" : self.texteXSD += self.texteTypeAbstrait
         self.texteXSD += self.texteCata
-        self.texteXSD += self.texteElt
+        #self.texteXSD += self.texteElt
        
         toutesLesKeys=set()
         texteKeyRef = ""
@@ -1054,8 +1082,8 @@ class X_JDC_CATA :
             c.code=self.code
             c.dumpXsd()
             
-            
             self.texteSimple   += c.texteSimple
             self.texteComplexe += c.texteComplexe
-            c.texteElt=eltCompoDsSequenceInExtension.format(c.nom,self.code,c.nomDuTypePyxb)
+            #c.texteElt=eltCompoDsSequenceInExtension.format(c.nom,self.code,c.nomDuTypePyxb)
+            c.texteElt=eltEtape.format(c.nom,self.implement,c.nomDuTypePyxb,self.implement)
             self.texteCata   += c.texteElt
index 151eb99932a59d8ca3b795d87ee63a68f01eb929..0e753fe0fe8187a91c3318c0f8d2e7b6db37dbc4 100644 (file)
@@ -1,28 +1,27 @@
 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/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
+texteDebutNiveau2='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
+texteDebutNiveau3='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\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:{}="http://chercheurs.edf.com/logiciels/{}" xmlns="http://chercheurs.edf.com/logiciels/{}"  targetNamespace="http://chercheurs.edf.com/logiciels/{}" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0">'
 
 # SIMP
-
-
-debutSimpleType        = '\t<xs:simpleType name="{}">\n'
-debutSimpleTypeSsNom   = '\t<xs:simpleType>\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'
+debutSimpleType      = '\t<xs:simpleType name="{}">\n'
+debutSimpleTypeSsNom = '\t<xs:simpleType>\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'
-UsingASSDkeyRefDeclaration ='\n\t<xs:keyref name="{}_Name_ref_a{}" refer="{}:Key_Name_For_{}"> \n\t\t<xs:selector xpath="{}"/>\n\t\t<xs:field xpath="."/>\n\t</xs:keyref>\n'
+eltDsSequence       = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+eltWithDefautDsSequence    = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}" default="{}"/>\n'
+UsingASSDkeyRefDeclaration = '\n\t<xs:keyref name="{}_Name_ref_a{}" refer="{}:Key_Name_For_{}"> \n\t\t<xs:selector xpath="{}"/>\n\t\t<xs:field xpath="."/>\n\t</xs:keyref>\n'
 #    <xs:key name="Key_Name_For_ElementarySurface">
 #            <xs:selector xpath="./Vimmp:CDM/Vimmp:Geometric_Domain/Vimmp:Surface"/>
 #            <xs:field    xpath="./Vimmp:SurfaceName"/>
@@ -35,28 +34,32 @@ UsingASSDkeyRefDeclaration ='\n\t<xs:keyref name="{}_Name_ref_a{}" refer="{}:Key
 
 
 # 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'
-
+debutTypeCompo      = '\t<xs:complexType name="{}" >\n'
+debutTypeCompoEtape = '\t <xs:complexContent>\n\t  <xs:extension base="T_step_{}">\n'
+finTypeCompoEtape   = '\t  </xs:extension>\n\t </xs:complexContent>\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'
+
+# ETAPE 
+eltEtape = '\t<xs:element name="{}" type="{}:{} substitution="step_{}"/>\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'
-#choiceDsBloc='\t\t\t<xs:choice minOccurs={}>\n'
-debutChoiceDsBloc='<xs:choice>\n'
-debutChoiceDsBlocAvecMin='<xs:choice minOccurs="{}">\n'
-finChoiceDsBloc='</xs:choice>\n'
-debSequenceDsBloc='<xs:sequence>\n'
-finSequenceDsBloc='</xs:sequence>\n'
+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'
+#choiceDsBloc     = '\t\t\t<xs:choice minOccurs={}>\n'
+debutChoiceDsBloc = '<xs:choice>\n'
+debutChoiceDsBlocAvecMin = '<xs:choice minOccurs="{}">\n'
+finChoiceDsBloc   = '</xs:choice>\n'
+debSequenceDsBloc = '<xs:sequence>\n'
+finSequenceDsBloc = '</xs:sequence>\n'
 debutTypeSubstDsBlocFactorise = '\t<xs:group name="{}">\n'
-finTypeSubstDsBlocFactorise = '\t</xs:group>\n'
-debutUnion = '\t\t\t<xs:union>\n'
-finUnion = '\t\t\t</xs:union>\n'
+finTypeSubstDsBlocFactorise   = '\t</xs:group>\n'
+debutUnion        = '\t\t\t<xs:union>\n'
+finUnion          = '\t\t\t</xs:union>\n'
 
 
 
@@ -68,23 +71,27 @@ producingASSDkeyRefDeclaration='\t<xs:key name="Key_Name_For_{}">\n\t\t<xs:selec
 texteFieldUnitaire="./{}:{}/@name |"
 
 # CATA
-debutTypeCata = '\t<xs:complexType name="T_{}">\n\t\t<xs:choice minOccurs="0" maxOccurs="unbounded">\n'
+debutTypeCata     = '\t<xs:complexType name="T_{}">\n\t\t<xs:choice minOccurs="0" maxOccurs="unbounded">\n'
 debutTypeCataExtension = '\t<xs:complexType name="T_{}">\n'
-finTypeCata   = '\t\t</xs:choice>\n\t</xs:complexType>\n'
-finSchema     = '</xs:schema>'
-eltCata = '\t<xs:element name="{}" type="{}:{}"/>\n'
-eltCodeSpecDsCata='\t\t\t<xs:element ref="{}_Abstract" minOccurs="0" maxOccurs="1"/>\n'
-includeCata = '<xs:include schemaLocation="cata_{}.xsd" />\n\n'
-fermeEltCata   = '\t</xs:element>\n'
+finTypeCata       = '\t\t</xs:choice>\n\t</xs:complexType>\n'
+finSchema         = '</xs:schema>'
+#eltCata           = '\t<xs:element name="{}" type="{}:{}"/>\n'
+#eltCodeSpecDsCata = '\t\t\t<xs:element ref="{}_Abstract" minOccurs="0" maxOccurs="1"/>\n'
+#fermeEltCata      = '\t</xs:element>\n'
+includeCata       = '<xs:include schemaLocation="cata_{}.xsd" />\n\n'
+
 
 # EXTENSION
 debutExtension = '\t\t<xs:complexContent>\n\t\t<xs:extension base="{}:T_{}_Abstract">\n\t\t<xs:choice minOccurs="0" maxOccurs="unbounded">\n'
-finExtension = '\t\t</xs:choice>\n\t\t</xs:extension>\n\t\t</xs:complexContent>\n'
+finExtension  = '\t\t</xs:choice>\n\t\t</xs:extension>\n\t\t</xs:complexContent>\n'
 
 # TYPE ABSTRAIT
-eltAbstrait                = '\t<xs:complexType name="T_{}_Abstract" abstract="true"/>\n\t<xs:element name="{}_Abstract" type="{}:T_{}_Abstract"/>\n'
-implementeAbstrait = '\t<xs:element name="{}" type="{}:{}" substitutionGroup="{}:{}_Abstract"/>\n'
-#implementeAbstrait = '\t<xs:element name="CFD1" type="CFDCommun:T_CFD1" substitutionGroup="CFDCommun:CFD1_Abstract"/>
+eltAbstraitCataPPal  = '\t<xs:complexType name="T_step_{}" abstract="true"/>\n'
+eltAbstraitCataFils  = '\t<xs:complexType name="T_step_{}" abstract="true"\n\t\t<xs:complexContent>\n\t\t\t<xs:extension base="{}:T_step_{}"/>\n\t\t</xs:complexContent>\n\t</xs:complexType>\n'
+eltCata = '\t<xs:element name="{}" type="{}:T_{}"/>\n\t\t<xs:complexType name="T_{}">\n\t\t  <xs:choice minOccurs="0" maxOccurs="unbounded">\n\t\t\t<xs:element ref="step_{}" minOccurs="0" maxOccurs="1"/>\n\t\t  </xs:choice>\n\t\t</xs:complexType>\n'
+
+#\n\t<xs:element name="{}_Abstract" type="{}:T_{}_Abstract"/>\n'
+#implementeAbstrait  = '\t<xs:element name="{}" type="{}:{}" substitutionGroup="{}:{}_Abstract"/>\n'
 
 if __name__ == '__main__' :
     print ('ne fait rien')
index b407b8a46b2edef8b35dec99272400da539f5014..d5a916979c65f17b8fd070e92f73d133b9619118 100644 (file)
@@ -251,8 +251,6 @@ class ReaderCata (ReaderCataCommun):
       
       # pointeur pour le dumpXSD
       self.cata.JdC.cata=self.cata
-      if self.cata.JdC.fichierSource == None :  self.cata.JdC.fichierSource = self.cata.__file__
-      self.cata.JdC.codeQuiImporte = os.path.basename(self.cata.JdC.fichierSource).split('.')[0][5:]
       
       self.cata.modeleMetier = modeleMetier
       if not self.cata :
index 5610bb1ff87a071a94220aaf8dc4a902c6369643..890481a6e38c3e0ff7c1850bd3daea874db2dd15 100644 (file)
@@ -214,7 +214,7 @@ class TypeProtocol(PProtocol):
             else:
                 print(("Type non encore gere %s" %type_permis))
         raise ValError(
-            tr("%s (de type %s) n'est pas d'un type autorise: %s %s") % (repr(obj), type(obj), typ, err))
+            tr("%s (de type %s) n'est pas d'un type autorise: %s ") % (repr(obj), type(obj), typ))
 
     def isComplexe(self, valeur):
         """ Retourne 1 si valeur est un complexe, 0 sinon """