X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Ihm%2FI_MCSIMP.py;h=53067a77173f406a321d8bd92691654f7278be9f;hb=5ecef0dc64055f54a1f864b979e58cc05f1c9f4a;hp=d610ae06e45a4e05672b494db3d349d8e0d96078;hpb=914f305827eb7149ca83335eb4980b6996b011f1;p=tools%2Feficas.git diff --git a/Ihm/I_MCSIMP.py b/Ihm/I_MCSIMP.py index d610ae06..53067a77 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): @@ -62,6 +64,8 @@ class MCSIMP(I_OBJECT.OBJECT): if hasattr(type_permis, "__class__") and type_permis.__class__.__name__ == 'Matrice': self.monType=type_permis return self.valideMatrice(cr=cr) + if self.definition.siValide != None : + self.definition.siValide(self) return Validation.V_MCSIMP.MCSIMP.isvalid(self,cr=cr) def GetNomConcept(self): @@ -87,35 +91,38 @@ 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) : - if self.valeur==[]: return str(self.valeur) + 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: @@ -124,7 +131,7 @@ class MCSIMP(I_OBJECT.OBJECT): ## 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 @@ -142,30 +149,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 @@ -176,7 +184,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 @@ -187,7 +195,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 @@ -199,7 +207,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 @@ -210,7 +218,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 @@ -229,9 +237,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] @@ -357,7 +365,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)) @@ -398,7 +406,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() @@ -416,13 +424,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) @@ -436,7 +444,8 @@ class MCSIMP(I_OBJECT.OBJECT): # Glut Horrible pour les matrices ??? if sd.__class__.__name__== "variable": for type_permis in self.definition.type: - if type(type_permis) == types.InstanceType: + #if type(type_permis) == types.InstanceType: + # a voir en python 3 if type_permis.__class__.__name__ == 'Matrice' : self.state="changed" self.isvalid() @@ -452,14 +461,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) @@ -520,8 +529,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) : @@ -624,7 +633,7 @@ class MCSIMP(I_OBJECT.OBJECT): 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