/usr/share/pyshared/Noyau/ascheckers.py is in eficas 6.4.0-1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | #@ MODIF ascheckers Noyau DATE 07/09/2009 AUTEUR COURTOIS M.COURTOIS
# -*- coding: iso-8859-1 -*-
# RESPONSABLE COURTOIS M.COURTOIS
# CONFIGURATION MANAGEMENT OF EDF VERSION
# ======================================================================
# COPYRIGHT (C) 1991 - 2007 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 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.
#
# 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.
# ======================================================================
class Parmi(object):
"""Classe qui exprime une contrainte multiple pour un attribut"""
def __init__(self, *args):
self.values = list(args)
def add_value(self, value ):
if value not in self.values:
self.values.append( value )
def __call__(self, obj, name, value, log ):
if value not in self.values:
log.err( obj, "l'attribut %s=%r n'est pas dans %r" % (name, value, self.values) )
def __repr__(self):
l = [ "Parmi(", ]
g = [ repr(v) for v in self.values ]
l.append( ", ".join(g) )
l.append( ")" )
return "".join( l )
class CheckLog(object):
"""Un validateur qui enregistre toutes les erreurs trouvées.
checkedXXX répond True si la "marq" courante est inférieure ou égale
à la celle de la dernière vérification.
Si on incrémentait "marq" à chaque étape, on revérifie à chaque fois.
"""
def __init__(self):
self.msg = []
self.names = {}
self.cksums = {}
self.optional = False
self._marq = 1
self._lastmarq = self._marq
self._debug = False
self._profond = False # True pour forcer des vérifications plus profondes
def log(self, level, obj, msg ):
if obj :
self.msg.append( (level, obj.nomj(), msg) )
else :
self.msg.append( (level, 'None', msg) )
def err(self, obj, msg ):
self.log( 0, obj, msg )
def warn(self, obj, msg ):
self.log( 1, obj, msg )
def visitOJB(self, obj):
key = obj.nomj()
self.names[key] = self._marq
def checkSumOJB(self, obj, sd, maj='non'):
# vérifie que le checksum de obj n'a pas changé
# sd : concept qui contient obj
# maj='maj', l'opérateur a le droit de modifier ojb
if obj.exists :
import md5
m=md5.new()
m.update(str(obj.get()))
cksum=m.digest()
nom=obj.nomj()
if not self.cksums.has_key(nom) :
self.cksums[nom]=cksum
else :
if self.cksums[nom] != cksum :
self.cksums[nom] = cksum
#if maj.strip()=='maj' and nom[0:8].strip()==sd.nomj.nomj[0:8].strip() :
# Remarque : ne pas tester 'maj' premet de résoudre (un peu) le problème
# posé par la commande DETRUIRE
if nom[0:8].strip()==sd.nomj.nomj[0:8].strip() :
pass
else :
self.err(obj,'Le checksum a changé')
def visitAsBase(self, obj):
key = (obj.nomj(), obj.__class__.__name__)
self.names[key] = self._marq
def force(self, force=False):
if not force:
self._marq = 1
else:
self._lastmarq += 1
self._marq = self._lastmarq
def checkedOJB(self, obj):
key = obj.nomj()
res = self.names.get(key, 0) >= self._marq
self.help_dbg([key,], res)
return res
def checkedAsBase(self, obj):
key = (obj.nomj(), obj.__class__.__name__)
res = self.names.get(key, 0) >= self._marq
self.help_dbg(key, res)
return res
def help_dbg(self, key, res):
if self._debug:
if res:
s = 'ignore'
else:
s = 'check '
print '#DBG %6d %s : %s' % (self._marq, s, ', '.join(key))
def __str__(self):
d = { 0: "E", 1:"W" }
return "\n".join( [ "%s:%s: %s" % (d[l],n,m)
for l,n,m in self.msg ])
class CheckFail(CheckLog):
"""Un validateur qui lève une exception
dès la première erreur"""
def err(self, obj, msg ):
raise AssertionError("%s: %s" % (obj.nomj(), msg) )
|