X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Noyau%2FN_SIMP.py;h=4eff2a724a8d81f19dfd4e3695312801e5842776;hb=aaf54e27d39904aa7b9a56498e9f08f3e71351f7;hp=70720181c007912df605d65dccce2396a382d9bf;hpb=f1ca95b49f76bed371d3bc90fc94bd12a6f17523;p=tools%2Feficas.git diff --git a/Noyau/N_SIMP.py b/Noyau/N_SIMP.py index 70720181..4eff2a72 100644 --- a/Noyau/N_SIMP.py +++ b/Noyau/N_SIMP.py @@ -1,139 +1,115 @@ -#@ MODIF N_SIMP Noyau DATE 14/09/2004 AUTEUR MCOURTOI 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. +# coding=utf-8 +# 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. # -# 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. -# -# -# ====================================================================== +# 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 """ Ce module contient la classe de definition SIMP - qui permet de spécifier les caractéristiques des mots clés simples + qui permet de spécifier les caractéristiques des mots clés simples """ +from __future__ import absolute_import import types -import N_ENTITE -import N_MCSIMP - -class SIMP(N_ENTITE.ENTITE): - """ - Classe pour definir un mot cle simple - - Cette classe a deux attributs de classe - - - class_instance qui indique la classe qui devra etre utilisée - pour créer l'objet qui servira à controler la conformité d'un - mot-clé simple avec sa définition - - - label qui indique la nature de l'objet de définition (ici, SIMP) - - """ - class_instance = N_MCSIMP.MCSIMP - label = 'SIMP' - - def __init__(self,typ,fr="",ang="",statut='f',into=None,defaut=None, - min=1,max=1,homo=1,position ='local', - val_min = '**',val_max='**',docu="",validators=None): - - """ - Un mot-clé simple est caractérisé par les attributs suivants : - - - type : cet attribut est obligatoire et indique le type de valeur attendue - - - fr : - - - ang : - - - statut : - - - into : - - - defaut : - - - min - - - max - - - homo - - - position - - - val_min - - - val_max - - - docu - """ - N_ENTITE.ENTITE.__init__(self,validators) - # Initialisation des attributs - if type(typ) == types.TupleType : - self.type=typ - else : - self.type=(typ,) - self.fr=fr - self.ang=ang - self.statut=statut - self.into=into - self.defaut=defaut - self.min=min - self.max=max - self.homo=homo - self.position = position - self.val_min=val_min - self.val_max=val_max - self.docu = docu - - def verif_cata(self): - """ - Cette methode sert à valider les attributs de l'objet de définition - de la classe SIMP - """ - if type(self.min) != types.IntType : - if self.min != '**': - self.cr.fatal("L'attribut 'min' doit etre un entier : "+`self.min`) - if type(self.max) != types.IntType : - if self.max != '**' : - self.cr.fatal("L'attribut 'max' doit etre un entier : "+`self.max`) - if self.min > self.max : - self.cr.fatal("Nombres d'occurrence min et max invalides : %s %s" %(`self.min`,`self.max`)) - if type(self.fr) != types.StringType : - self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" +`self.fr`) - if self.statut not in ['o','f','c','d']: - self.cr.fatal("L'attribut 'statut' doit valoir 'o','f','c' ou 'd' : %s" %`self.statut`) - if self.homo != 0 and self.homo != 1 : - self.cr.fatal("L'attribut 'homo' doit valoir 0 ou 1 : %s" %`self.homo`) - if self.into != None : - if type(self.into) != types.TupleType : - self.cr.fatal("L'attribut 'into' doit etre un tuple : %s" %`self.into`) - if self.position not in ['local','global','global_jdc']: - self.cr.fatal("L'attribut 'position' doit valoir 'local','global' ou 'global_jdc' : %s" %`self.position`) - if self.validators and not self.validators.verif_cata(): - self.cr.fatal("Un des validateurs est incorrect. Raison : "+self.validators.cata_info) - - def __call__(self,val,nom,parent=None): - """ - Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self) - de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent) - """ - return self.class_instance(nom=nom,definition=self,val=val,parent=parent) - - - +from . import N_ENTITE +from . import N_MCSIMP +class SIMP(N_ENTITE.ENTITE): + """ + Classe pour definir un mot cle simple + + Cette classe a deux attributs de classe + + - class_instance qui indique la classe qui devra etre utilisée + pour créer l'objet qui servira à controler la conformité d'un + mot-clé simple avec sa définition + + - label qui indique la nature de l'objet de définition (ici, SIMP) + + """ + class_instance = N_MCSIMP.MCSIMP + label = 'SIMP' + + def __init__(self, typ,ang="", fr="", statut='f', into=None, intoSug = None,siValide = None, defaut=None, + min=1, max=1, homo=1, position='local', + val_min=float('-inf'), val_max=float('inf'), docu="", validators=None, + sug=None): + """ + Un mot-clé simple est caractérisé par les attributs suivants : + - type : cet attribut est obligatoire et indique le type de valeur attendue + - fr : chaîne documentaire en français + - statut : obligatoire ou facultatif ou caché + - into : valeurs autorisées + - intoSug : valeurs possibles mais des valeurs autres du bon type peuvent etre entrees par l utilsateur + - defaut : valeur par défaut + - min : nombre minimal de valeurs + - max : nombre maximal de valeurs + - homo : ? + - ang : doc + - position : si global, le mot-clé peut-être lu n'importe où dans la commande + - val_min : valeur minimale autorisée + - val_max : valeur maximale autorisée + - docu : ? + - sug : ? + """ + N_ENTITE.ENTITE.__init__(self, validators) + # Initialisation des attributs + if type(typ) == tuple: + self.type = typ + else: + self.type = (typ,) + self.fr = fr + self.statut = statut + self.into = into + self.intoSug = intoSug + self.siValide = siValide + self.defaut = defaut + self.min = min + self.max = max + self.homo = homo + self.position = position + self.val_min = val_min + self.val_max = val_max + self.docu = docu + self.sug = sug + self.ang=ang + if self.max == '**' : self.max = float('inf') + if self.val_max == '**' : self.val_max = float('inf') + if self.min == '**' : self.min = float('-inf') + if self.val_min == '**' : self.val_min = float('-inf') + + def verif_cata(self): + """ + Cette methode sert à valider les attributs de l'objet de définition + de la classe SIMP + """ + self.check_min_max() + self.check_fr() + self.check_statut() + self.check_homo() + self.check_into() + self.check_position() + self.check_validators() + + def __call__(self, val, nom, parent=None): + """ + Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self) + de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent) + """ + return self.class_instance(nom=nom, definition=self, val=val, parent=parent)