diff options
Diffstat (limited to 'scripts/lib/wic/3rdparty/pykickstart/errors.py')
-rw-r--r-- | scripts/lib/wic/3rdparty/pykickstart/errors.py | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/scripts/lib/wic/3rdparty/pykickstart/errors.py b/scripts/lib/wic/3rdparty/pykickstart/errors.py deleted file mode 100644 index a234d99d43..0000000000 --- a/scripts/lib/wic/3rdparty/pykickstart/errors.py +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | # | ||
2 | # errors.py: Kickstart error handling. | ||
3 | # | ||
4 | # Chris Lumens <clumens@redhat.com> | ||
5 | # | ||
6 | # This copyrighted material is made available to anyone wishing to use, modify, | ||
7 | # copy, or redistribute it subject to the terms and conditions of the GNU | ||
8 | # General Public License v.2. This program is distributed in the hope that it | ||
9 | # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the | ||
10 | # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
11 | # See the GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License along with | ||
14 | # this program; if not, write to the Free Software Foundation, Inc., 51 | ||
15 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat | ||
16 | # trademarks that are incorporated in the source code or documentation are not | ||
17 | # subject to the GNU General Public License and may only be used or replicated | ||
18 | # with the express permission of Red Hat, Inc. | ||
19 | # | ||
20 | """ | ||
21 | Error handling classes and functions. | ||
22 | |||
23 | This module exports a single function: | ||
24 | |||
25 | formatErrorMsg - Properly formats an error message. | ||
26 | |||
27 | It also exports several exception classes: | ||
28 | |||
29 | KickstartError - A generic exception class. | ||
30 | |||
31 | KickstartParseError - An exception for errors relating to parsing. | ||
32 | |||
33 | KickstartValueError - An exception for errors relating to option | ||
34 | processing. | ||
35 | |||
36 | KickstartVersionError - An exception for errors relating to unsupported | ||
37 | syntax versions. | ||
38 | """ | ||
39 | import gettext | ||
40 | _ = lambda x: gettext.ldgettext("pykickstart", x) | ||
41 | |||
42 | def formatErrorMsg(lineno, msg=""): | ||
43 | """Properly format the error message msg for inclusion in an exception.""" | ||
44 | if msg != "": | ||
45 | mapping = {"lineno": lineno, "msg": msg} | ||
46 | return _("The following problem occurred on line %(lineno)s of the kickstart file:\n\n%(msg)s\n") % mapping | ||
47 | else: | ||
48 | return _("There was a problem reading from line %s of the kickstart file") % lineno | ||
49 | |||
50 | class KickstartError(Exception): | ||
51 | """A generic exception class for unspecific error conditions.""" | ||
52 | def __init__(self, val = ""): | ||
53 | """Create a new KickstartError exception instance with the descriptive | ||
54 | message val. val should be the return value of formatErrorMsg. | ||
55 | """ | ||
56 | Exception.__init__(self) | ||
57 | self.value = val | ||
58 | |||
59 | def __str__ (self): | ||
60 | return self.value | ||
61 | |||
62 | class KickstartParseError(KickstartError): | ||
63 | """An exception class for errors when processing the input file, such as | ||
64 | unknown options, commands, or sections. | ||
65 | """ | ||
66 | def __init__(self, msg): | ||
67 | """Create a new KickstartParseError exception instance with the | ||
68 | descriptive message val. val should be the return value of | ||
69 | formatErrorMsg. | ||
70 | """ | ||
71 | KickstartError.__init__(self, msg) | ||
72 | |||
73 | def __str__(self): | ||
74 | return self.value | ||
75 | |||
76 | class KickstartValueError(KickstartError): | ||
77 | """An exception class for errors when processing arguments to commands, | ||
78 | such as too many arguments, too few arguments, or missing required | ||
79 | arguments. | ||
80 | """ | ||
81 | def __init__(self, msg): | ||
82 | """Create a new KickstartValueError exception instance with the | ||
83 | descriptive message val. val should be the return value of | ||
84 | formatErrorMsg. | ||
85 | """ | ||
86 | KickstartError.__init__(self, msg) | ||
87 | |||
88 | def __str__ (self): | ||
89 | return self.value | ||
90 | |||
91 | class KickstartVersionError(KickstartError): | ||
92 | """An exception class for errors related to using an incorrect version of | ||
93 | kickstart syntax. | ||
94 | """ | ||
95 | def __init__(self, msg): | ||
96 | """Create a new KickstartVersionError exception instance with the | ||
97 | descriptive message val. val should be the return value of | ||
98 | formatErrorMsg. | ||
99 | """ | ||
100 | KickstartError.__init__(self, msg) | ||
101 | |||
102 | def __str__ (self): | ||
103 | return self.value | ||