Debian Codegraph @

wxgeometrie/pylib/erreurs.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 ##--------------------------------------#######
4 # Erreurs #
5 ##--------------------------------------#######
6 # WxGeometrie
7 # Dynamic geometry, graph plotter, and more for french mathematic teachers.
8 # Copyright (C) 2005-2013 Nicolas Pourcelot
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24 # version unicode
25
26
27 # généré par :
28 # import exceptions;l = [" " + key + ": u\"\"\"" + val.__doc__ + "\"\"\"" for key, val in vars(exceptions).items() if not isinstance(val, basestring)];l.sort();print "messages = {\n" + ",\n".join(l) + "\n}"
29
30
31 messages = {
32 ArithmeticError: """Erreur de calcul.""",
33 AssertionError: """Assertion non vérifiée.""",
34 AttributeError: """L'attribut n'existe pas.""",
35 BaseException: """Common base class for all exceptions""",
36 DeprecationWarning: """Base class for warnings about deprecated features.""",
37 EOFError: """Read beyond end of file.""",
38 EnvironmentError: """Base class for I/O related errors.""",
39 Exception: """Common base class for all non-exit exceptions.""",
40 FloatingPointError: """Erreur de calcul (flottants).""",
41 FutureWarning: """Base class for warnings about constructs that will change semantically
42 in the future.""",
43 GeneratorExit: """Request that a generator exit.""",
44 IOError: """Impossible d'écrire sur le périphérique.""",
45 ImportWarning: """Base class for warnings about probable mistakes in module imports""",
46 ImportError: """Module introuvable.""",
47 IndentationError: """Indentation incorrecte.""",
48 IndexError: """Indexation incorrecte.""",
49 KeyError: """Référence non trouvée (clé).""",
50 KeyboardInterrupt: """Program interrupted by user.""",
51 LookupError: """Base class for lookup errors.""",
52 MemoryError: """Manque de mémoire.""",
53 NameError: """Nom inconnu.""",
54 NotImplementedError: """Method or function hasn't been implemented yet.""",
55 OSError: """OS system call failed.""",
56 OverflowError: """Le résultat est trop grand.""",
57 PendingDeprecationWarning: """Base class for warnings about features which will be deprecated
58 in the future.""",
59 ReferenceError: """Référence non trouvée (référence faible).""",
60 RuntimeError: """Unspecified run-time error.""",
61 RuntimeWarning: """Base class for warnings about dubious runtime behavior.""",
62 StopIteration: """Fin d'itération.""",
63 SyntaxError: """Erreur de syntaxe.""",
64 SyntaxWarning: """Base class for warnings about dubious syntax.""",
65 SystemError: """Internal error in the Python interpreter.""",
66 SystemExit: """Request to exit from the interpreter.""",
67 TabError: """Mélange de tabulations et d'espaces.""",
68 TypeError: """Type d'argument incorrect.""",
69 UnboundLocalError: """Référence à une variable non définie.""",
70 UnicodeDecodeError: """Problème de décodage (caractères spéciaux).""",
71 UnicodeEncodeError: """Problème d'encodage (caractères spéciaux).""",
72 UnicodeError: """Erreur unicode (caractères spéciaux).""",
73 UnicodeTranslateError: """Erreur unicode (caractères spéciaux).""",
74 UnicodeWarning: """Problème d'encodage.""",
75 UserWarning: """Base class for warnings generated by user code.""",
76 ValueError: """Valeur incorrecte.""",
77 Warning: """Base class for warning categories.""",
78 ZeroDivisionError: """Division par zéro."""
79 }
80
81 try:
82 messages[WindowsError] = """MS-Windows OS system call failed."""
83 except NameError: # non défini sous Linux par exemple
84 pass
85
86 def message(erreur):
87 try:
88 super(erreur) # si ça marche, c'est une "classe", sinon, c'est une instance
89 return messages.get(erreur, "Erreur inconnue.")
90 except TypeError:
91 return messages.get(type(erreur), "Erreur inconnue.")