Salome HOME
etat provisoire pour sauvegarde avant vacances. non stable
[tools/eficas.git] / Extensions / eficas_exception.py
1 # -*- coding: utf-8 -*-
2 # copyright 2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
3 # contact http://www.logilab.fr -- mailto:contact@logilab.fr
4 #
5 # This program is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 2.1 of the License, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License along
16 # with this program. If not, see <http://www.gnu.org/licenses/>.
17 """
18 Creates the ``EficasException`` class for the EDF Eficas application.
19 This class supports the internationalization mechanism provided in 
20 the ``i18n`` module.
21 """
22
23 class EficasException(Exception):
24     """
25     ``EficasException`` class, which embeds the translation mechanism.
26     In case the input message is already passed through the translation
27     mechanism, the translation mechanism defined in this class would
28     have no effect, since its input would not be among the source
29     strings to be translated.
30     """
31     def __init__(self, msg=""):
32         """
33         Initializes the EficasException instances. The output message,
34         stored in the ``args`` attribute, is fitted with the translation
35         mechanism.
36         """
37         Exception.__init__(self)
38         #import sys, os
39         #sys.path.append(os.path.realpath(".."))
40         from Extensions.i18n import tr
41         self.args = (tr(msg),)
42     
43
44 if __name__ == "__main__":
45     import sys
46     raise EficasException(sys.argv[1])