3 # Chris Lumens <clumens@redhat.com>
5 # Copyright 2009 Red Hat, Inc.
7 # This copyrighted material is made available to anyone wishing to use, modify,
8 # copy, or redistribute it subject to the terms and conditions of the GNU
9 # General Public License v.2. This program is distributed in the hope that it
10 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17 # trademarks that are incorporated in the source code or documentation are not
18 # subject to the GNU General Public License and may only be used or replicated
19 # with the express permission of Red Hat, Inc.
26 from pykickstart.base import *
27 from pykickstart.errors import *
28 from pykickstart.parser import *
29 from pykickstart.version import *
32 gettext.textdomain("pykickstart")
33 _ = lambda x: gettext.ldgettext("pykickstart", x)
35 def getCommandSet(handler):
36 return set(handler.commands.keys())
39 return set(map(lambda o: o.get_opt_string(), lst))
43 sys.stdout.write("%s " % e)
47 op = OptionParser(usage="usage: %prog [options]")
48 op.add_option("-f", "--from", dest="f")
49 op.add_option("-t", "--to", dest="t")
51 (opts, extra) = op.parse_args(sys.argv[1:])
53 if not opts.f or not opts.t:
54 print(_("You must specify two syntax versions."))
58 fromHandler = makeVersion(opts.f)
59 toHandler = makeVersion(opts.t)
60 except KickstartVersionError as e:
61 print(_("The version %s is not supported by pykickstart")) % e
64 fromCmdSet = getCommandSet(fromHandler)
65 toCmdSet = getCommandSet(toHandler)
66 bothSet = fromCmdSet & toCmdSet
68 print(_("The following commands were removed in %s:")) % opts.t
69 printList(list(fromCmdSet - toCmdSet))
71 print(_("The following commands were deprecated in %s:")) % opts.t
72 printList(filter(lambda c: isinstance(toHandler.commands[c], DeprecatedCommand), list(bothSet)))
74 print(_("The following commands were added in %s:")) % opts.t
75 printList(list(toCmdSet - fromCmdSet))
83 deprecatedOptList = []
86 fromCmd = fromHandler.commands[cmd]
87 toCmd = toHandler.commands[cmd]
89 if not hasattr(fromCmd, "op") or not hasattr(toCmd, "op"):
92 fromOpt = fromCmd.op.option_list
93 toOpt = toCmd.op.option_list
95 newOptList = getOptSet(toOpt) - getOptSet(fromOpt)
96 removedOptList = getOptSet(fromOpt) - getOptSet(toOpt)
97 deprecatedOptList = getOptSet(filter(lambda cmd: cmd.deprecated == 1, toOpt))
99 if len(newOptList) > 0:
100 print(_("The following options were added to the %s command in %s:")) % (cmd, opts.t)
101 printList(list(newOptList))
104 if len(deprecatedOptList) > 0:
105 print(_("The following options were deprecated from the %s command in %s:")) % (cmd, opts.t)
106 printList(list(deprecatedOptList))
109 if len(removedOptList) > 0:
110 print(_("The following options were removed from the %s command in %s:")) % (cmd, opts.t)
111 printList(list(removedOptList))