Remove the --start and --end options since anaconda no longer uses them.
[pykickstart.git] / tools / ksverdiff
blob3135fc8a117e4d11c57704525941df0bf030514d
1 #!/usr/bin/python2
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. 
22 import optparse
23 import os
24 import sys
25 import warnings
26 from pykickstart.base import *
27 from pykickstart.errors import *
28 from pykickstart.parser import *
29 from pykickstart.version import *
31 import gettext
32 gettext.textdomain("pykickstart")
33 _ = lambda x: gettext.ldgettext("pykickstart", x)
35 def getCommandSet(handler):
36     return set(handler.commands.keys())
38 def getOptSet(lst):
39     return set(map(lambda o: o.get_opt_string(), lst))
41 def printList(lst):
42     for e in lst:
43         sys.stdout.write("%s " % e)
45     print
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."))
55     os._exit(1)
57 try:
58     fromHandler = makeVersion(opts.f)
59     toHandler = makeVersion(opts.t)
60 except KickstartVersionError, e:
61     print(_("The version %s is not supported by pykickstart") % str(e))
62     os._exit(1)
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))
77 print
79 for cmd in bothSet:
80     printed = False
82     newOptList = []
83     deprecatedOptList = []
84     removedOptList = []
86     fromCmd = fromHandler.commands[cmd]
87     toCmd = toHandler.commands[cmd]
89     if not hasattr(fromCmd, "op") or not hasattr(toCmd, "op"):
90         continue
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))
102         printed = True
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))
107         printed = True
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))
112         printed = True
114     if printed:
115         print