X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Ihm%2FI_MCSIMP.py;h=dd02069d3cdf4cbcc0541b2e4ab42a11e918aeea;hb=217a9ce2f303b098ad28d282bb0df2dfeeeed3c2;hp=e5fae814d3a9202583d15f92a7a084efc3001932;hpb=e61aff6d6540bbc57004cc8276163587a4efb51b;p=tools%2Feficas.git diff --git a/Ihm/I_MCSIMP.py b/Ihm/I_MCSIMP.py index e5fae814..dd02069d 100644 --- a/Ihm/I_MCSIMP.py +++ b/Ihm/I_MCSIMP.py @@ -17,19 +17,21 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import types,string +from __future__ import absolute_import +import types import traceback from copy import copy -from repr import Repr +from six.moves.reprlib import Repr from Extensions.i18n import tr from Extensions.eficas_exception import EficasException +from six.moves import range myrepr = Repr() myrepr.maxstring = 100 myrepr.maxother = 100 from Noyau.N_utils import repr_float import Validation -import CONNECTOR +from . import CONNECTOR # Attention : les classes ASSD,.... peuvent etre surchargees # dans le package Accas. Il faut donc prendre des precautions si @@ -48,9 +50,9 @@ import Accas from Extensions import parametre from Extensions import param2 -import I_OBJECT -import CONNECTOR -from I_VALIDATOR import ValError,listProto +from . import I_OBJECT +from . import CONNECTOR +from .I_VALIDATOR import ValError,listProto class MCSIMP(I_OBJECT.OBJECT): @@ -87,43 +89,47 @@ class MCSIMP(I_OBJECT.OBJECT): if self.valeur == None : return None - elif type(self.valeur) == types.FloatType : + elif type(self.valeur) == float : # Traitement d'un flottant isole txt = str(self.valeur) clefobj=self.GetNomConcept() - if self.jdc.appli.appliEficas.dict_reels.has_key(clefobj): - if self.jdc.appli.appliEficas.dict_reels[clefobj].has_key(self.valeur): + if clefobj in self.jdc.appli.appliEficas.dict_reels : + if self.valeur in self.jdc.appli.appliEficas.dict_reels[clefobj]: txt=self.jdc.appli.appliEficas.dict_reels[clefobj][self.valeur] - elif type(self.valeur) in (types.ListType,types.TupleType) : + elif type(self.valeur) in (list,tuple) : + if self.valeur==[] or self.valeur == (): return str(self.valeur) # Traitement des listes txt='(' sep='' for val in self.valeur: - if type(val) == types.FloatType : + if type(val) == float : clefobj=self.GetNomConcept() - if self.jdc.appli.appliEficas.dict_reels.has_key(clefobj): - if self.jdc.appli.appliEficas.dict_reels[clefobj].has_key(val): + if clefobj in self.jdc.appli.appliEficas.dict_reels: + if val in self.jdc.appli.appliEficas.dict_reels[clefobj]: txt=txt + sep +self.jdc.appli.appliEficas.dict_reels[clefobj][val] else : txt=txt + sep + str(val) else : txt=txt + sep + str(val) else: - if isinstance(val,types.TupleType): + if isinstance(val,tuple): texteVal='(' for i in val : - texteVal = texteVal + str(i)+',' + if isinstance(i, bytes) : texteVal = texteVal +"'"+str(i)+"'," + else : texteVal = texteVal + str(i)+',' texteVal=texteVal[:-1]+')' - else : texteVal=str(val) + else : + if isinstance(val,bytes): texteVal="'"+str(val)+"'" + else :texteVal=str(val) txt = txt + sep+ texteVal - if len(txt) > 200: - #ligne trop longue, on tronque - txt=txt+" ..." - break +## if len(txt) > 200: +## #ligne trop longue, on tronque +## txt=txt+" ..." +## break sep=',' # cas des listes de tuples de longueur 1 - if isinstance(val,types.TupleType) and len(self.valeur) == 1 : txt=txt+',' + if isinstance(val,tuple) and len(self.valeur) == 1 : txt=txt+',' txt=txt+')' else: # Traitement des autres cas @@ -141,30 +147,31 @@ class MCSIMP(I_OBJECT.OBJECT): Retourne une chaine de caractere representant la valeur de self """ val=self.valeur - if type(val) == types.FloatType : + if type(val) == float : clefobj=self.GetNomConcept() - if self.jdc.appli.appliEficas.dict_reels.has_key(clefobj): - if self.jdc.appli.appliEficas.appliEficas.dict_reels[clefobj].has_key(val): + if clefobj in self.jdc.appli.appliEficas.dict_reels : + if val in self.jdc.appli.appliEficas.appliEficas.dict_reels[clefobj] : return self.jdc.appli.appliEficas.dict_reels[clefobj][val] - if type(val) != types.TupleType : + if type(val) != tuple : try: return val.get_name() except: return val else : + if val ==() or val == [] : return val s='( ' for item in val : try : s=s+item.get_name()+',' except: - s=s+`item`+',' + s=s+repr(item)+',' s=s+' )' return s def wait_bool(self): for typ in self.definition.type: try : - if typ == types.BooleanType: return True + if typ == bool: return True except : pass return False @@ -175,7 +182,7 @@ class MCSIMP(I_OBJECT.OBJECT): qui n'existe pas encore (type CO()), 0 sinon """ for typ in self.definition.type: - if type(typ) == types.ClassType or isinstance(typ,type): + if type(typ) == type or isinstance(typ,type): if issubclass(typ,CO) : return 1 return 0 @@ -186,7 +193,7 @@ class MCSIMP(I_OBJECT.OBJECT): ou derive, 0 sinon """ for typ in self.definition.type: - if type(typ) == types.ClassType or isinstance(typ,type): + if type(typ) == type or isinstance(typ,type): if issubclass(typ,ASSD) and not issubclass(typ,GEOM): return 1 return 0 @@ -198,7 +205,7 @@ class MCSIMP(I_OBJECT.OBJECT): Retourne 0 dans le cas contraire """ for typ in self.definition.type: - if type(typ) == types.ClassType or isinstance(typ,type): + if type(typ) == type or isinstance(typ,type): if typ.__name__ in ("GEOM","ASSD","geom","assd") or issubclass(typ,GEOM) : return 1 return 0 @@ -209,7 +216,7 @@ class MCSIMP(I_OBJECT.OBJECT): Retourne 0 dans le cas contraire """ for typ in self.definition.type: - if type(typ) == types.ClassType or isinstance(typ,type): + if type(typ) == type or isinstance(typ,type): if issubclass(typ,GEOM) : return 1 return 0 @@ -228,9 +235,9 @@ class MCSIMP(I_OBJECT.OBJECT): """ if self.valeur == None: return [] - elif type(self.valeur) == types.TupleType: + elif type(self.valeur) == tuple: return list(self.valeur) - elif type(self.valeur) == types.ListType: + elif type(self.valeur) == list: return self.valeur else: return [self.valeur] @@ -356,7 +363,7 @@ class MCSIMP(I_OBJECT.OBJECT): if new_valeur in ('True','False') and 'TXM' in self.definition.type : valeur=self.eval_val_item(str(new_valeur)) return new_valeur - if type(new_valeur) in (types.ListType,types.TupleType): + if type(new_valeur) in (list,tuple): valeurretour=[] for item in new_valeur : valeurretour.append(self.eval_val_item(item)) @@ -397,7 +404,7 @@ class MCSIMP(I_OBJECT.OBJECT): return None def update_concept(self,sd): - if type(self.valeur) in (types.ListType,types.TupleType) : + if type(self.valeur) in (list,tuple) : if sd in self.valeur: self.init_modif() self.fin_modif() @@ -415,13 +422,13 @@ class MCSIMP(I_OBJECT.OBJECT): du concept sd Attention aux matrices """ - if type(self.valeur) == types.TupleType : + if type(self.valeur) == tuple : if sd in self.valeur: self.init_modif() self.valeur=list(self.valeur) self.valeur.remove(sd) self.fin_modif() - elif type(self.valeur) == types.ListType: + elif type(self.valeur) == list: if sd in self.valeur: self.init_modif() self.valeur.remove(sd) @@ -451,14 +458,14 @@ class MCSIMP(I_OBJECT.OBJECT): du concept old_sd """ #print "replace_concept",old_sd,sd - if type(self.valeur) == types.TupleType : + if type(self.valeur) == tuple : if old_sd in self.valeur: self.init_modif() self.valeur=list(self.valeur) i=self.valeur.index(old_sd) self.valeur[i]=sd self.fin_modif() - elif type(self.valeur) == types.ListType: + elif type(self.valeur) == list: if old_sd in self.valeur: self.init_modif() i=self.valeur.index(old_sd) @@ -519,8 +526,8 @@ class MCSIMP(I_OBJECT.OBJECT): # Attention : possible probleme avec include # A priori il n'y a pas de raison de retirer les concepts non existants # avant etape. En fait il s'agit uniquement eventuellement de ceux crees par une macro - l_sd_avant_etape = self.jdc.get_contexte_avant(self.etape).values() - if type(self.valeur) in (types.TupleType,types.ListType) : + l_sd_avant_etape = list(self.jdc.get_contexte_avant(self.etape).values()) + if type(self.valeur) in (tuple,list) : l=[] for sd in self.valeur: if isinstance(sd,ASSD) : @@ -618,8 +625,12 @@ class MCSIMP(I_OBJECT.OBJECT): def valideMatrice(self,cr): #Attention, la matrice contient comme dernier tuple l ordre des variables + if self.valideEnteteMatrice()==False : + self.set_valid(0) + if cr == "oui" : self.cr.fatal(tr("La matrice n'a pas le bon entete")) + return 0 if self.monType.methodeCalculTaille != None : - apply (MCSIMP.__dict__[self.monType.methodeCalculTaille],(self,)) + MCSIMP.__dict__[self.monType.methodeCalculTaille](*(self,)) try : #if 1 : ok=0 @@ -640,11 +651,23 @@ class MCSIMP(I_OBJECT.OBJECT): self.set_valid(0) return 0 + def NbDeVariables(self): listeVariables=self.jdc.get_variables(self.etape) self.monType.nbLigs=len(listeVariables) self.monType.nbCols=len(listeVariables) + def valideEnteteMatrice(self): + if self.jdc.get_distributions(self.etape) == () or self.valeur == None : return 0 + if self.jdc.get_distributions(self.etape) != self.valeur[0] : return 0 + return 1 + + def changeEnteteMatrice(self): + a=[self.jdc.get_distributions(self.etape),] + for t in self.valeur[1:]: + a.append(t) + self.valeur=a + def NbDeDistributions(self): listeVariables=self.jdc.get_distributions(self.etape)