Add new RHEL7 logvol objects to master
[pykickstart.git] / pykickstart / commands / eula.py
blobba905ae1aa64a6fa68a065113ed92809045bf8c9
2 # Copyright (C) 2013 Red Hat, Inc.
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions of
6 # the GNU General Public License v.2, or (at your option) any later version.
7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY expressed or implied, including the implied warranties of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10 # Public License for more details. You should have received a copy of the
11 # GNU General Public License along with this program; if not, write to the
12 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13 # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
14 # source code or documentation are not subject to the GNU General Public
15 # License and may only be used or replicated with the express permission of
16 # Red Hat, Inc.
18 # Red Hat Author(s): Vratislav Podzimek <vpodzime@redhat.com>
21 from pykickstart.base import KickstartCommand
22 from pykickstart.errors import KickstartValueError, formatErrorMsg
23 from pykickstart.options import KSOptionParser
25 import gettext
26 _ = lambda x: gettext.ldgettext("pykickstart", x)
28 class F20_Eula(KickstartCommand):
29 """The 'eula' kickstart command"""
31 def __init__(self, *args, **kwargs):
32 KickstartCommand.__init__(self, *args, **kwargs)
33 self.op = self._getParser()
34 self.agreed = kwargs.get("agreed", False)
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
39 if self.agreed:
40 retval += "# License agreement\n"
41 retval += "eula %s\n" % self._getArgsAsStr()
43 return retval
45 def _getArgsAsStr(self):
46 if self.agreed:
47 return "--agreed"
48 else:
49 return ""
51 def _getParser(self):
52 op = KSOptionParser()
53 # people would struggle remembering the exact word
54 op.add_option("--agreed", "--agree", "--accepted", "--accept",
55 dest="agreed", action="store_true", default=False)
57 return op
59 def parse(self, args):
60 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
61 self._setToSelf(self.op, opts)
63 if len(extra) != 0:
64 raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "eula"))
66 if not self.agreed:
67 raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("Kickstart command eula expects the --agreed option")))
69 return self