X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Noyau%2FN_MCSIMP.py;h=438b8ee08c744c93df6e9b894b88432fb83f5692;hb=2c5a8689b9c6cc46804fd268d416d1de2777059e;hp=5a4093f7102030f6ac7ddefed96081060acce4f5;hpb=7e72a676f0cd6fcb60eb9515ba411fdc6dfabc1a;p=tools%2Feficas.git diff --git a/Noyau/N_MCSIMP.py b/Noyau/N_MCSIMP.py index 5a4093f7..438b8ee0 100644 --- a/Noyau/N_MCSIMP.py +++ b/Noyau/N_MCSIMP.py @@ -1,27 +1,25 @@ -#@ MODIF N_MCSIMP Noyau DATE 13/10/2008 AUTEUR COURTOIS M.COURTOIS # -*- coding: iso-8859-1 -*- -# CONFIGURATION MANAGEMENT OF EDF VERSION -# ====================================================================== -# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG -# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY -# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY -# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR -# (AT YOUR OPTION) ANY LATER VERSION. +# Copyright (C) 2007-2013 EDF R&D # -# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT -# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF -# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU -# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE -# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, -# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. -# -# -# ====================================================================== -""" +""" Ce module contient la classe MCSIMP qui sert à controler la valeur d'un mot-clé simple par rapport à sa définition portée par un objet de type ENTITE @@ -29,10 +27,11 @@ from copy import copy -from Noyau.N_ASSD import ASSD,assd +from Noyau.N_ASSD import ASSD from Noyau.N_CO import CO import N_OBJECT from N_CONVERT import ConversionFactory +from N_types import force_list, is_sequence class MCSIMP(N_OBJECT.OBJECT): """ @@ -72,7 +71,7 @@ class MCSIMP(N_OBJECT.OBJECT): self.etape = None def GETVAL(self,val): - """ + """ Retourne la valeur effective du mot-clé en fonction de la valeur donnée. Defaut si val == None """ @@ -85,15 +84,25 @@ class MCSIMP(N_OBJECT.OBJECT): def get_valeur(self): """ Retourne la "valeur" d'un mot-clé simple. - Cette valeur est utilisée lors de la création d'un contexte + Cette valeur est utilisée lors de la création d'un contexte d'évaluation d'expressions à l'aide d'un interpréteur Python """ v = self.valeur - # Singleton : on retourne l'element - # Permet aussi d'ignorer l'erreur : concept=COMMANDE(), - # ou 'concept' est un tuple de longueur 1 a cause de la virgule. - if type(v) in (list, tuple) and len(v) == 1: + # Si singleton et max=1, on retourne la valeur. + # Si une valeur simple et max='**', on retourne un singleton. + # (si liste de longueur > 1 et max=1, on sera arrêté plus tard) + # Pour accepter les numpy.array, on remplace : "type(v) not in (list, tuple)" + # par "not has_attr(v, '__iter__')". + if v is None: + pass + elif is_sequence(v) and len(v) == 1 and self.definition.max == 1: v = v[0] + elif not is_sequence(v) and self.definition.max != 1: + v = (v, ) + # traitement particulier pour les complexes ('RI', r, i) + if 'C' in self.definition.type and self.definition.max != 1 \ + and v[0] in ('RI', 'MP'): + v = (v, ) return v def get_val(self): @@ -134,7 +143,7 @@ class MCSIMP(N_OBJECT.OBJECT): self.etape=parent.etape def get_sd_utilisees(self): - """ + """ Retourne une liste qui contient la ou les SD utilisée par self si c'est le cas ou alors une liste vide """ @@ -148,15 +157,15 @@ class MCSIMP(N_OBJECT.OBJECT): return l def get_sd_mcs_utilisees(self): - """ + """ Retourne la ou les SD utilisée par self sous forme d'un dictionnaire : - Si aucune sd n'est utilisée, le dictionnaire est vide. - Sinon, la clé du dictionnaire est le mot-clé simple ; la valeur est la liste des sd attenante. Exemple :: - { 'VALE_F': [ , - ] } + { 'VALE_F': [ , + ] } """ l=self.get_sd_utilisees() dico = {} @@ -169,10 +178,8 @@ class MCSIMP(N_OBJECT.OBJECT): Cette methode retourne l'objet MCSIMP self s'il a le concept co comme valeur. """ - lval=self.valeur - if type(self.valeur) not in (list, tuple): - lval=(self.valeur,) - if co in lval:return [self,] + if co in force_list(self.valeur): + return [self,] return [] def get_all_co(self): @@ -180,10 +187,5 @@ class MCSIMP(N_OBJECT.OBJECT): Cette methode retourne la liste de tous les concepts co associés au mot cle simple """ - lval=self.valeur - if type(self.valeur) not in (list, tuple): - lval=(self.valeur,) - l=[] - for c in lval: - if isinstance(c,CO) or hasattr(c,"_etape"):l.append(c) - return l + return [co for co in force_list(self.valeur) \ + if isinstance(co, CO) and co.is_typco()]