From 13001107844e4a618ca09ebaf1b78c480c303f2f Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Wed, 3 Apr 2019 14:31:08 +0200 Subject: [PATCH] pour partage eric --- Efi2Xsd/AccasXsd.py | 19 +++++++++-- Efi2Xsd/MCAccasXsd.py | 15 ++++++--- Efi2Xsd/balises.py | 64 +++++--------------------------------- InterfaceQT4/browser.py | 3 +- InterfaceQT4/editor.py | 3 +- InterfaceQT4/readercata.py | 9 ++++-- JP/cata_Vimmp.py | 8 ++--- Noyau/N_OBJECT.py | 37 ++++++++++++++++------ Noyau/N_SIMP.py | 4 ++- 9 files changed, 77 insertions(+), 85 deletions(-) diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index c276eec6..95c2ff58 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -3,6 +3,7 @@ import sys,os import types import Accas +import inspect # CONTEXT est accessible (__init__.py de Noyau) @@ -111,7 +112,7 @@ class X_definitionComposee (X_definition): self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb) texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils() self.texteComplexe = texteComplexeVenantDesFils + self.texteComplexe - self.texteComplexe += finTypeCompo + if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompo else : self.texteComplexe = "" @@ -150,7 +151,13 @@ class X_FACT (X_definitionComposee): # --------------------------------- class X_OPER (X_definitionComposee): # --------------------------------- - pass + def dumpXsd(self): + X_definitionComposee.dumpXsd(self) + self.texteComplexe += operAttributeName + self.texteComplexe += attributeTypeForASSD + self.texteComplexe += attributeTypeUtilisateurName.format(self.sd_prod.__name__) + self.texteComplexe += finTypeCompo + # ---------------------------------- class X_PROC (X_definitionComposee): @@ -309,6 +316,13 @@ class X_JDC_CATA : def dumpXsd(self): + #for name, obj in inspect.getmembers(self.module): + # if inspect.isclass(obj): + # if issubclass(obj,Accas.UserASSD) : + # source = inspect.getsourcefile(obj) + # if source.split('/')[-1] != "A_ASSD.py" : + # typeASSD= 'UserASSD' + # textDeclaration += debutAccasClass.format('T_'+obj.__name__,typeASSD) self.texteSimple = "" self.texteComplexe = "" self.nomDuTypePyxb='T_'+self.code @@ -323,6 +337,7 @@ class X_JDC_CATA : self.texteElt=eltCata.format(self.code,self.code, self.nomDuTypePyxb) self.texteXSD = texteDebut.format(self.code,self.code,self.code) + #self.texteXSD += textDeclaration self.texteXSD += self.texteSimple self.texteXSD += self.texteCata self.texteXSD += self.texteElt diff --git a/Efi2Xsd/MCAccasXsd.py b/Efi2Xsd/MCAccasXsd.py index 68dce819..ff7a8dab 100755 --- a/Efi2Xsd/MCAccasXsd.py +++ b/Efi2Xsd/MCAccasXsd.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- import sys,os +import inspect import traceback def trace(): traceback.print_stack() @@ -17,6 +18,8 @@ try : #import pyxb.utils.domutils except : pass +from Accas import A_ASSD + class X_OBJECT: # ------------- @@ -173,15 +176,17 @@ class X_MCSIMP(X_OBJECT): if self.objPyxb : self.objPyxb.objAccas=self #print ('X_MCSIMP', self.nom, self.objPyxb, ) #print ('fin X_MCSIMP', self.objPyxb, self.nom,self) - if self.nom=="species_pair_parameters_potential_type" : print ('X_MCSIMP buildObjPyxb', self.nom ) def setValeurObjPyxb(self,newVal): if not self.cata.modeleMetier : return print ('------------------------------------------------------------------') print ('dans setValeurObjPyxb MCSIMP ', self.nom) + if inspect.isclass(newVal) and issubclass(newVal,A_ASSD) : newVal = newVal.nom + print (newVal) #print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb) + if newVal != None : nvlObj=self.maClasseModeleMetier(newVal) #else : nvlObj=self.maClasseModeleMetier() # a priori impossible mais ? @@ -409,11 +414,11 @@ class X_JDC (X_MCCOMPO): # OK seulement si sequence (choice ? ...) # 01 11 2018 # ne fonctionne pas : a reecrire avec les fonctions addObjPyxb et ReconstruitPerePyxb - print ( 'hhhhhhhhhhhhhhh enregistreEtapePyxb hhhhhhhhhhhhhhhhhhhhhhhhh') - print ('enregistre ds ',self, etape.nom, 'indice = ', indice) + #print ( 'hhhhhhhhhhhhhhh enregistreEtapePyxb hhhhhhhhhhhhhhhhhhhhhhhhh') + #print ('enregistre ds ',self, etape.nom, 'indice = ', indice) if not self.cata.modeleMetier : return - import traceback - traceback.print_stack() + #import traceback + #traceback.print_stack() self.objPyxb.append(etape.objPyxb) etape.perePyxb=self #print (self.objPyxb.orderedContent()) diff --git a/Efi2Xsd/balises.py b/Efi2Xsd/balises.py index 74896ac7..73e6b82e 100644 --- a/Efi2Xsd/balises.py +++ b/Efi2Xsd/balises.py @@ -34,6 +34,13 @@ 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 ' @@ -41,60 +48,5 @@ eltCata = '\t\n' if __name__ == '__main__' : - nomElt='Simple' - nomDuType='T_Simple' - nomDuTypeBase='int' - nomDuComplexe='T_Complexe' - nomDuCode='monCode' - minOccurs=1 - maxOccurs=1 - nomDuTypePyxb = "T_simulation_title" - nomDuTypeDeBase = 'string' - into=None - - isListe=False - if isListe : texteSimple = debutTypeSimpleListe.format(nomDuTypePyxb, nomDuTypeDeBase) - else : texteSimple = debutTypeSimple.format (nomDuTypePyxb, nomDuTypeDeBase) - if into != None: - texteSimple = self.texteSimple + ">\n" - for val in into : - texteSimple += withInto.format(val) - texteSimple += finWithInto - else : - texteSimple += fermeBalise - texteSimple += finTypeSimple - - #print texteSimple - #exit() - - isListe=True - if isListe : texteSimple = debutTypeSimpleListe.format(nomDuTypePyxb, nomDuTypeDeBase) - else : texteSimple = debutTypeSimple.format (nomDuTypePyxb, nomDuTypeDeBase) - if into != None: - texteSimple = self.texteSimple + ">\n" - for val in into : - texteSimple += withInto.format(val) - texteSimple += finWithInto - else : - texteSimple += fermeBalise - texteSimple += finTypeSimple - - print texteSimple - exit() - - texteSimple=typeSimple.format(nomDuType, nomDuTypeBase) - texteElt=eltDsSequence.format(nomElt,nomDuCode,nomDuType,minOccurs,maxOccurs) - - minOccurs=0 - texteComplexe=debutTypeComplexe.format(nomDuComplexe) - texteComplexe+=texteElt - texteComplexe+=finTypeComplexe - texteEltComplexe=eltDsSequence.format(nomElt,nomDuCode,nomDuType,minOccurs,maxOccurs) - - texteCata=debutTypeCata.format(nomDuCode) - texteCata+=texteEltComplexe - texteCata+=finTypeCata - - eltRacine=eltCata.format(nomDuCode, 'T_'+nomDuCode) - print (texteSimple+texteComplexe+texteCata+eltRacine) + print ('ne fait rien') diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index d1bbb146..6cefdc79 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -292,7 +292,6 @@ class JDCNode(QTreeWidgetItem,GereRegles): self.item.connect("valid",self.onValid,()) self.item.connect("supp" ,self.onSupp,()) self.item.connect("add" ,self.onAdd,()) - self.item.connect("reconstruit" ,self.onReconstruit,()) self.state="" self.fenetre=None @@ -685,7 +684,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): # #------------------------------------------------------------------ def onValid(self): - print ("onValid pour ", self.item.nom) + #print ("onValid pour ", self.item.nom) if self.JESUISOFF==1 : return if hasattr(self,'fenetre') and self.fenetre: try : diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index a389926c..f7babdf8 100755 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -1002,7 +1002,7 @@ class JDCEditor(JDCEditorSsIhm,Ui_baseWidget,QWidget): #----------------------------------------- #print ("je passe ds initSplitterSizes", nbWidget) - if self.code in [ 'Adao', 'ADAO','MAP' ] : self.splitterSizes3=[1,1550,150] + if self.code in [ 'Adao', 'ADAO','MAP' ] : self.splitterSizes3=[1,1550,300] #elif self.code in [ 'MAP'] : self.splitterSizes3=[700,300] else : self.splitterSizes3=[150,1000,300] @@ -1020,6 +1020,7 @@ class JDCEditor(JDCEditorSsIhm,Ui_baseWidget,QWidget): if nbWidget==2 : newSizes=self.splitterSizes2 if nbWidget==3 : newSizes=self.splitterSizes3 #self.inhibeSplitter = 1 + #print (newSizes) self.splitter.setSizes(newSizes) #self.inhibeSplitter = 0 QApplication.processEvents() diff --git a/InterfaceQT4/readercata.py b/InterfaceQT4/readercata.py index 272a1ef8..ee476071 100644 --- a/InterfaceQT4/readercata.py +++ b/InterfaceQT4/readercata.py @@ -204,9 +204,10 @@ class ReaderCata (ReaderCataCommun): try : nomCataXsd = os.path.splitext(os.path.basename(self.fic_cata))[0]+'_genere' pathCata = os.path.dirname(self.fic_cata)+'/raw/'+nomCataXsd+'.py' - modeleMetier=__import__('raw.cata_DPD_genere',fromlist=['']) -# import imp -# modeleMetier= imp.load_source(nomCataXsd,pathCata) +# modeleMetier=__import__('raw.cata_DPD_genere',fromlist=['']) + import imp + modeleMetier= imp.load_source(nomCataXsd,pathCata) + #print ('_________________________', modeleMetier) except : print ('______________ poum import cata_genere ') modeleMetier = None @@ -214,6 +215,8 @@ class ReaderCata (ReaderCataCommun): modeleMetier = None self.cata = self.importCata(self.fic_cata) + # pointeur pour le dumpXSD + self.cata.JdC.module=self.cata self.cata.modeleMetier = modeleMetier if not self.cata : try: diff --git a/JP/cata_Vimmp.py b/JP/cata_Vimmp.py index 78e46006..404a0284 100755 --- a/JP/cata_Vimmp.py +++ b/JP/cata_Vimmp.py @@ -34,11 +34,7 @@ class Tuple: def info(self): return "Tuple de %s elements" % self.ntuple -#liste_Objets_Surface_Elementaire = [] -class Surface_Elementaire (UserASSD): - def __init__(self, nom): - ASSD.__init__(self) - self.setName(nom) +class Surface_Elementaire (UserASSD): pass def champ (nomDelaContante, labels ,nbReels ) : # ajouter les extensions pour le fichier et les blocs associes @@ -138,7 +134,7 @@ Etude = PROC (nom = 'Etude', ), ),# fin b_CAO surface_Elementaire=SIMP(statut= 'o',typ= 'TXM',max='**', siValide=creeSurfaceElementaire), - essai=SIMP(statut = 'ee', typ = Surface_Elementaire), + essai=SIMP(statut= 'o',typ= Surface_Elementaire), ), # fin Domaine_Geometrique diff --git a/Noyau/N_OBJECT.py b/Noyau/N_OBJECT.py index 25228f5a..b10ae922 100644 --- a/Noyau/N_OBJECT.py +++ b/Noyau/N_OBJECT.py @@ -119,19 +119,26 @@ class OBJECT(object): newlisteNomsObjsCrees = [] listeSupprimees = [] change=False - for v in self.valeur: + if not isinstance(self.valeur,(list, tuple)) : valTraitee = (self.valeur,) + else : valTraitee = self.valeur + + for v in valTraitee: if not (v in self.listeNomsObjsCrees): - newObj=classeACreer(v) change=True + newObj=classeACreer(v) if v in list(self.jdc.sds_dict.keys()): if not isinstance (self.jdc.sds_dict[v], classeACreer): - self.valeur.remove(v) - continue + if not type(self.valeur) in (list, tuple) :self.Valeur=None + else : self.valeur.remove(v) + self.valeur=None + self.state = 'undetermined' + self.isValid() + return self.jdc.sds_dict[v] = newObj newObj.sdnom = v newlisteNomsObjsCrees.append(v) for oldv in self.listeNomsObjsCrees : - if oldv not in self.valeur : + if oldv not in valTraitee : change=True listeSupprimees.append(self.jdc.sds_dict[oldv]) self.jdc.sds_dict.pop(oldv) @@ -141,10 +148,22 @@ class OBJECT(object): if not change : return if classeACreer in list(self.jdc.utilise_un_sds_dict.keys()): for MC in self.jdc.utilise_un_sds_dict[classeACreer] : - if isinstance(MC.valeur, str) and MC.valeur in list(self.jdc.sds_dict.keys()): - MC.valeur=self.jdc.sds_dict[MC.valeur] - if MC.valeur in listeSupprimees: - MC.valeur=None + if MC.definition.max == 1 : + if isinstance(MC.valeur, str) and MC.valeur in list(self.jdc.sds_dict.keys()): + MC.valeur=self.jdc.sds_dict[MC.valeur] + else : + for val in MC.valeur : + newVal=[] + if isinstance(val, str) and val in list(self.jdc.sds_dict.keys()): + newVal.append(self.jdc.sds_dict[MC.valeur]) + MC.valeur=newVal + if MC.definition.max == 1 : + if MC.valeur in listeSupprimees: + MC.valeur=None + else : + for val in MC.valeur : + if val in listeSupprimees: + MC.valeur=remove(val) MC.state = 'undetermined' MC.isValid() diff --git a/Noyau/N_SIMP.py b/Noyau/N_SIMP.py index 49306e70..2f5db69b 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, - sug=None,fenetreIhm=None, attribut=False): + sug=None,fenetreIhm=None, attribut=False, creeDesObjetsDeType = None): """ Un mot-clé simple est caractérisé par les attributs suivants : - type : cet attribut est obligatoire et indique le type de valeur attendue @@ -70,6 +70,7 @@ class SIMP(N_ENTITE.ENTITE): - sug : valeur suggere - fenetreIhm : si widget particulier - attribut : si projection XSD sur attribut + - creeDesObjetsDeType : type des UserASSD si siValide en cree """ #print (self) #import traceback @@ -105,6 +106,7 @@ class SIMP(N_ENTITE.ENTITE): if self.val_min == '**' : self.val_min = float('-inf') self.fenetreIhm=fenetreIhm self.attribut = attribut + self.creeDesObjetsDeType = creeDesObjetsDeType def verifCata(self): """ -- 2.39.2