summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/3rdparty/pykickstart/errors.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2014-08-08 15:53:52 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-11 10:53:12 +0100
commitd8f9d05baee3abd4feb0a5b2f2afe467e919c6b9 (patch)
treeedc6ba90a220ad5bbba41998c3c5c82e1e97760d /scripts/lib/wic/3rdparty/pykickstart/errors.py
parenta43c1f94205d95c6eb77af2f0a494b4143f9eaf8 (diff)
downloadpoky-d8f9d05baee3abd4feb0a5b2f2afe467e919c6b9.tar.gz
wic: Rename /mic to /wic
As well as any other stray instances of mic in the codebase that can be removed. We don't really need to carry around legacy naming, and the history is in git. (From OE-Core rev: 598b120406dc1d2b7e377bd1ab6f0acbef034b22) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/3rdparty/pykickstart/errors.py')
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/errors.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/scripts/lib/wic/3rdparty/pykickstart/errors.py b/scripts/lib/wic/3rdparty/pykickstart/errors.py
new file mode 100644
index 0000000000..a234d99d43
--- /dev/null
+++ b/scripts/lib/wic/3rdparty/pykickstart/errors.py
@@ -0,0 +1,103 @@
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"""
21Error handling classes and functions.
22
23This module exports a single function:
24
25 formatErrorMsg - Properly formats an error message.
26
27It 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"""
39import gettext
40_ = lambda x: gettext.ldgettext("pykickstart", x)
41
42def 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
50class 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
62class 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
76class 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
91class 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