Salome HOME
bug
[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 from __future__ import absolute_import
24 class EficasException(Exception):
25     """
26     ``EficasException`` class, which embeds the translation mechanism.
27     In case the input message is already passed through the translation
28     mechanism, the translation mechanism defined in this class would
29     have no effect, since its input would not be among the source
30     strings to be translated.
31     """
32     def __init__(self, msg=""):
33         """
34         Initializes the EficasException instances. The output message,
35         stored in the ``args`` attribute, is fitted with the translation
36         mechanism.
37         """
38         Exception.__init__(self)
39         #import sys, os
40         #sys.path.append(os.path.realpath(".."))
41         from Extensions.i18n import tr
42         self.args = (tr(msg),)
43     
44
45 if __name__ == "__main__":
46     import sys
47     raise EficasException(sys.argv[1])