X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Noyau%2FN_ENTITE.py;h=d9387e293f3259ba4d0018d18af0194cd37a4e31;hb=9f4ff7ed9afd87c96e11d61e442e39e5511f60d1;hp=4ae2a01aa76b49819df9291a17c63e4c76ac0c3d;hpb=479b2809fce994d6fc2fa7046bac6405daa0d706;p=tools%2Feficas.git diff --git a/Noyau/N_ENTITE.py b/Noyau/N_ENTITE.py index 4ae2a01a..d9387e29 100644 --- a/Noyau/N_ENTITE.py +++ b/Noyau/N_ENTITE.py @@ -1,21 +1,23 @@ # coding=utf-8 -# Copyright (C) 2007-2013 EDF R&D +# person_in_charge: mathieu.courtois at edf.fr +# ====================================================================== +# COPYRIGHT (C) 1991 - 2015 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. # -# 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 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 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 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. # -# 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 +# ====================================================================== """ @@ -23,15 +25,23 @@ de toutes les classes de definition d'EFICAS. """ +from __future__ import absolute_import +from __future__ import print_function +try : + from builtins import str + from builtins import object +except : + pass import re -import types -import N_CR -import N_OPS -import N_VALIDATOR -from strfunc import ufmt +from . import N_CR +from . import N_OPS +from . import N_VALIDATOR +import six +stringTypes = (str, six.text_type) -class ENTITE: + +class ENTITE(object): """ Classe de base pour tous les objets de definition : mots cles et commandes @@ -66,7 +76,7 @@ class ENTITE: directement Il s'agit principalement des mots cles """ - for k, v in self.entites.items(): + for k, v in list(self.entites.items()): v.pere = self v.nom = k @@ -91,17 +101,16 @@ class ENTITE: """ self.cr = self.CR() self.verif_cata() - for k, v in self.entites.items(): + for k, v in list(self.entites.items()): try: cr = v.report() cr.debut = u"Début " + v.__class__.__name__ + ' : ' + k cr.fin = u"Fin " + v.__class__.__name__ + ' : ' + k self.cr.add(cr) except: - self.cr.fatal( - _(u"Impossible d'obtenir le rapport de %s %s"), k, `v`) - print "Impossible d'obtenir le rapport de %s %s" % (k, `v`) - print "père =", self + self.cr.fatal("Impossible d'obtenir le rapport de %s %s" % (k, repr(v))) + print(("Impossible d'obtenir le rapport de %s %s" % (k, repr(v)))) + print(("père =", self)) return self.cr def verif_cata_regles(self): @@ -113,7 +122,7 @@ class ENTITE: for regle in self.regles: l = [] for mc in regle.mcs: - if not self.entites.has_key(mc): + if not mc in self.entites : l.append(mc) if l != []: txt = str(regle) @@ -124,7 +133,7 @@ class ENTITE: """Verifie la definition d'un objet composite (commande, fact, bloc).""" args = self.entites.copy() mcs = set() - for nom, val in args.items(): + for nom, val in list(args.items()): if val.label == 'SIMP': mcs.add(nom) # XXX @@ -141,7 +150,7 @@ class ENTITE: del args[nom] # seuls les blocs peuvent entrer en conflit avec les mcs du plus haut # niveau - for nom, val in args.items(): + for nom, val in list(args.items()): if val.label == 'BLOC': mcbloc = val.check_definition(parent) # XXX @@ -171,21 +180,21 @@ class ENTITE: def check_fr(self): """Vérifie l'attribut fr.""" - if type(self.fr) not in (str, unicode): + if type(self.fr) not in stringTypes: self.cr.fatal( _(u"L'attribut 'fr' doit être une chaine de caractères : %r"), self.fr) def check_docu(self): """Vérifie l'attribut docu.""" - if type(self.docu) not in (str, unicode): + if type(self.docu) not in stringTypes: self.cr.fatal( _(u"L'attribut 'docu' doit être une chaine de caractères : %r"), self.docu) def check_nom(self): """Vérifie l'attribut proc.""" - if type(self.nom) != types.StringType: + if type(self.nom) is not str: self.cr.fatal( _(u"L'attribut 'nom' doit être une chaine de caractères : %r"), self.nom) @@ -206,7 +215,7 @@ class ENTITE: def check_condition(self): """Vérifie l'attribut condition.""" if self.condition != None: - if type(self.condition) != types.StringType: + if type(self.condition) is not str: self.cr.fatal( _(u"L'attribut 'condition' doit être une chaine de caractères : %r"), self.condition) @@ -215,12 +224,12 @@ class ENTITE: def check_min_max(self): """Vérifie les attributs min/max.""" - if type(self.min) != types.IntType: - if self.min != '**': + if type(self.min) != int: + if self.min != '**'and self.min != float('-inf'): self.cr.fatal( _(u"L'attribut 'min' doit être un entier : %r"), self.min) - if type(self.max) != types.IntType: - if self.max != '**': + if type(self.max) != int: + if self.max != '**' and self.max != float('inf'): self.cr.fatal( _(u"L'attribut 'max' doit être un entier : %r"), self.max) if self.min > self.max: @@ -243,7 +252,7 @@ class ENTITE: def check_into(self): """Vérifie l'attribut into.""" if self.into != None: - if type(self.into) != types.TupleType: + if (type(self.into) not in (list, tuple)) and (type(self.into) != types.FunctionType) : self.cr.fatal( _(u"L'attribut 'into' doit être un tuple : %r"), self.into)