3 # Chris Lumens <clumens@redhat.com>
5 # Copyright 2009-2014 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.
24 from pykickstart
.base
import DeprecatedCommand
25 from pykickstart
.errors
import KickstartVersionError
26 from pykickstart
.version
import makeVersion
, versionMap
29 gettext
.textdomain("pykickstart")
30 _
= lambda x
: gettext
.ldgettext("pykickstart", x
)
32 def getCommandSet(handler
):
33 return set(handler
.commands
.keys())
36 return set(map(lambda o
: o
.get_opt_string(), lst
))
40 sys
.stdout
.write("%s " % e
)
44 op
= argparse
.ArgumentParser()
45 op
.add_argument("-f", "--from", dest
="f")
46 op
.add_argument("-t", "--to", dest
="t")
47 op
.add_argument("-l", "--listversions", dest
="listversions", action
="store_true",
49 help=_("list the available versions of kickstart syntax"))
51 opts
= op
.parse_args(sys
.argv
[1:])
54 for key
in sorted(versionMap
.keys()):
59 if not opts
.f
or not opts
.t
:
60 print(_("You must specify two syntax versions."))
64 fromHandler
= makeVersion(opts
.f
)
65 toHandler
= makeVersion(opts
.t
)
66 except KickstartVersionError
as exn
:
67 print(_("The version %s is not supported by pykickstart") % exn
)
70 fromCmdSet
= getCommandSet(fromHandler
)
71 toCmdSet
= getCommandSet(toHandler
)
72 bothSet
= fromCmdSet
& toCmdSet
74 print(_("The following commands were removed in %s:") % opts
.t
)
75 printList(list(fromCmdSet
- toCmdSet
))
77 print(_("The following commands were deprecated in %s:") % opts
.t
)
78 printList(filter(lambda c
: isinstance(toHandler
.commands
[c
], DeprecatedCommand
), list(bothSet
)))
80 print(_("The following commands were added in %s:") % opts
.t
)
81 printList(list(toCmdSet
- fromCmdSet
))
89 deprecatedOptList
= []
92 fromCmd
= fromHandler
.commands
[cmd
]
93 toCmd
= toHandler
.commands
[cmd
]
95 if not hasattr(fromCmd
, "op") or not hasattr(toCmd
, "op"):
98 fromOpt
= fromCmd
.op
.option_list
99 toOpt
= toCmd
.op
.option_list
101 newOptList
= getOptSet(toOpt
) - getOptSet(fromOpt
)
102 removedOptList
= getOptSet(fromOpt
) - getOptSet(toOpt
)
103 deprecatedOptList
= getOptSet(filter(lambda cmd
: cmd
.deprecated
== 1, toOpt
))
105 if len(newOptList
) > 0:
106 print(_("The following options were added to the %s command in %s:") % (cmd
, opts
.t
))
107 printList(list(newOptList
))
110 if len(deprecatedOptList
) > 0:
111 print(_("The following options were deprecated from the %s command in %s:") % (cmd
, opts
.t
))
112 printList(list(deprecatedOptList
))
115 if len(removedOptList
) > 0:
116 print(_("The following options were removed from the %s command in %s:") % (cmd
, opts
.t
))
117 printList(list(removedOptList
))