]> SALOME platform Git repositories - tools/eficas.git/blob - Noyau/N_SIMP.py
Salome HOME
reindent + copyright + merge manuel avec la V9_dev sauf repertoires metier
[tools/eficas.git] / Noyau / N_SIMP.py
1 # coding=utf-8
2 # Copyright (C) 2007-2021   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
20
21 """ Ce module contient la classe de definition SIMP
22     qui permet de spécifier les caractéristiques des mots clés simples
23 """
24
25 from __future__ import absolute_import
26 import types
27
28 import Accas
29 from Noyau import N_ENTITE
30 from Noyau import N_MCSIMP
31
32
33 class SIMP(N_ENTITE.ENTITE):
34
35     """
36      Classe pour definir un mot cle simple
37
38      Cette classe a deux attributs de classe
39
40      - class_instance qui indique la classe qui devra etre utilisée
41              pour créer l'objet qui servira à controler la conformité d'un
42              mot-clé simple avec sa définition
43
44      - label qui indique la nature de l'objet de définition (ici, SIMP)
45
46     """
47     class_instance = N_MCSIMP.MCSIMP
48     label = 'SIMP'
49
50     def __init__(self, typ,ang="", fr="", statut='f', into=None, intoSug = None,siValide = None, defaut=None,
51                  min=1, max=1, homo=1, position='local',filtre=None,
52                  val_min=float('-inf'), val_max=float('inf'), docu="", validators=None, nomXML=None,
53                  sug=None,fenetreIhm=None, attribut=False,  sortie='n', intoXML=None, metAJour=None,
54                  avecBlancs=False, unite=None):
55         """
56             Un mot-clé simple est caractérisé par les attributs suivants :
57             - type : cet attribut est obligatoire et indique le type de valeur attendue
58             - fr : chaîne documentaire en français
59             - statut : obligatoire ou facultatif ou caché
60             - into : valeurs autorisées
61             - intoSug : valeurs possibles mais des valeurs autres du bon type peuvent etre entrees par l utilsateur
62             - defaut : valeur par défaut
63             - min : nombre minimal de valeurs
64             - max : nombre maximal de valeurs
65             - homo : un certatin nb de choses qui il faut redispacher ailleurs (information, constant)
66             - ang : doc
67             - position : si global, le mot-clé peut-être lu n'importe où dans la commande
68             - val_min : valeur minimale autorisée
69             - val_max : valeur maximale autorisée
70             - docu : clef sur de la documentation utilisateur
71             - sug : valeur suggere
72             - fenetreIhm : si widget particulier
73             - attribut : si projection XSD sur attribut
74             - creeDesObjetsDeType : type des UserASSD si siValide en cree
75             - nomXML   : se projette en XSD avec un autre nom pour accepter les tirets
76             - sortie : force l ecriture dans le fichier de sortie (utile pour Telemac)
77         """
78         #print (self)
79         #import traceback
80         #traceback.print_stack()
81         #print (self)
82         N_ENTITE.ENTITE.__init__(self, validators)
83         # Initialisation des attributs
84         self.creeDesObjets = False
85         self.utiliseUneReference = False
86         self.creeDesObjetsDeType = None
87         self.utiliseDesObjetsDeType = None
88         if type(typ) == tuple:
89             self.type = typ
90         else:
91             self.type = (typ,)
92         for t in (self.type) :
93             try :
94                 if issubclass(t,Accas.UserASSDMultiple) :
95                     creeDesObjetsDeType = t
96                     self.utiliseUneReference = True
97                 elif issubclass(t,Accas.UserASSD) :
98                     creeDesObjetsDeType = t
99                     self.utiliseUneReference = True
100             except : pass
101             if t == 'createObject' : self.creeDesObjets=True
102         if self.utiliseUneReference :
103             if self.creeDesObjets :
104                 self.utiliseUneReference = False
105                 self.creeDesObjetsDeType = creeDesObjetsDeType
106             else : self.utiliseDesObjetsDeType = creeDesObjetsDeType
107         self.fr       = fr
108         self.statut   = statut
109         self.into     = into
110         self.intoSug  = intoSug
111         self.siValide = siValide
112         self.defaut   = defaut
113         self.min      = min
114         self.max      = max
115         self.homo     = homo
116         self.position = position
117         self.val_min  = val_min
118         self.val_max  = val_max
119         self.docu     = docu
120         self.sug      = sug
121         self.ang      = ang
122         if self.max     == '**' : self.max     = float('inf')
123         if self.val_max == '**' : self.val_max = float('inf')
124         if self.min     == '**' : self.min     = float('-inf')
125         if self.val_min == '**' : self.val_min = float('-inf')
126         self.fenetreIhm = fenetreIhm
127         self.attribut   = attribut
128         self.nomXML     = nomXML
129         self.intoXML    = intoXML
130         self.sortie     = sortie
131         self.filtre     = filtre
132         self.avecBlancs = avecBlancs
133         self.unite      = unite
134         if not(self.avecBlancs) and self.max > 1 and 'TXM' in self.type and self.into != None :
135             for val in self.into :
136                 if val.find(' ')  > -1: 
137                    self.avecBlancs = True  
138                    break
139         if not(self.avecBlancs) and self.max > 1 and 'TXM' in self.type and self.intoXML != None :
140             for val in self.intoXML :
141                 if val.find(' ')  > -1: 
142                    self.avecBlancs = True  
143                    break
144         if self.avecBlancs and not ('TXM' in self.type) : 
145             print ('definition incoherente avecBlanc et non texte pour ', self) 
146             exit()
147         if self.filtre  :
148             self.filtreExpression = self.filtre[0]
149             self.filtreVariables = self.filtre[1]
150         else :
151             self.filtreExpression = []
152             self.filtreVariables = []
153         self.metAJour=metAJour
154
155     def verifCata(self):
156         """
157             Cette methode sert à valider les attributs de l'objet de définition
158             de la classe SIMP
159         """
160         self.checkMinMax()
161         self.checkFr()
162         self.checkStatut()
163         self.checkHomo()
164         self.checkInto()
165         self.checkPosition()
166         self.checkValidators()
167
168
169     def __call__(self, val, nom, parent=None, objPyxbDeConstruction = None):
170         """
171             Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
172             de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
173         """
174         return self.class_instance(nom=nom, definition=self, val=val, parent=parent, objPyxbDeConstruction=objPyxbDeConstruction)