2 # Copyright (C) 2007-2021 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 Ce module contient la classe MCFACT qui sert à controler la valeur
23 d'un mot-clé facteur par rapport à sa définition portée par un objet
27 from __future__ import absolute_import
28 from . import N_MCCOMPO
31 class MCFACT(N_MCCOMPO.MCCOMPO):
37 def __init__(self, val, definition, nom, parent,dicoPyxbDeConstruction):
40 - val : valeur du mot clé simple
45 #print ('MCFACT', self, val, definition, nom, parent, dicoPyxbDeConstruction)
47 #traceback.print_stack()
48 self.dicoPyxbDeConstruction=dicoPyxbDeConstruction
49 if self.dicoPyxbDeConstruction :
50 self.objPyxbDeConstruction=self.dicoPyxbDeConstruction['objEnPyxb']
51 del self.dicoPyxbDeConstruction['objEnPyxb']
53 self.objPyxbDeConstruction=None
54 self.definition = definition
58 self.estIdentifiePar=None
59 self.valeur = self.getValeurEffective(self.val)
61 self.jdc = self.parent.jdc
62 self.niveau = self.parent.niveau
63 self.etape = self.parent.etape
65 # Le mot cle a été créé sans parent
69 self.mcListe = self.buildMc()
71 def getValeurEffective(self, val):
73 Retourne la valeur effective du mot-clé en fonction
74 de la valeur donnée. Defaut si val == None
76 if (val is None and hasattr(self.definition, 'defaut')):
77 return self.definition.defaut
83 Retourne la "valeur" d'un mot-clé facteur qui est l'objet lui-meme.
84 Cette valeur est utilisée lors de la création d'un contexte
85 d'évaluation d'expressions à l'aide d'un interpréteur Python
91 Une autre méthode qui retourne une "autre" valeur du mot clé facteur.
92 Elle est utilisée par la méthode getMocle
96 def __getitem__(self, key):
98 Dans le cas d un mot cle facteur unique on simule une liste de
103 return self.getMocle(key)
105 def accept(self, visitor):
107 Cette methode permet de parcourir l'arborescence des objets
108 en utilisant le pattern VISITEUR
110 visitor.visitMCFACT(self)
113 return self.definition.class_instance(val=None, nom=self.nom,
114 definition=self.definition, parent=self.parent)