2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2006 Red Hat, Inc.
6 # This software may be freely redistributed under the terms of the GNU
7 # general public license.
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software
11 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 Methods for working with kickstart versions.
16 This module defines several symbolic constants that specify kickstart syntax
17 versions. Each version corresponds roughly to one release of Red Hat Linux,
18 Red Hat Enterprise Linux, or Fedora Core as these are where most syntax
21 This module also exports several functions:
23 stringToVersion - Convert a string representation of a version number
24 into the symbolic constant.
26 returnClassForVersion - Given a version number, return the matching
27 handler class. This does not return an
28 instance of that class, however.
30 makeVersion - Given a version number, return an instance of the
31 matching handler class.
33 from pykickstart
.errors
import KickstartVersionError
35 # Symbolic names for internal version numbers.
40 # This always points at the latest version and is the default.
43 def stringToVersion(string
):
44 """Convert string into one of the provided version constants. Raises
45 KickstartVersionError if string does not match anything.
53 elif string
== "DEVEL":
56 raise KickstartVersionError(string
)
58 def returnClassForVersion(version
):
59 """Return the class of the syntax handler for version. version can be
60 either a string or the matching constant. Raises KickstartValueError
61 if version does not match anything.
64 version
= int(version
)
66 version
= stringToVersion(version
)
69 from pykickstart
.commands
.fc4
import FC4Version
72 from pykickstart
.commands
.fc5
import FC5Version
75 from pykickstart
.commands
.fc6
import FC6Version
78 raise KickstartVersionError(version
)
80 # Given a version of the kickstart syntax, this function imports the correct
81 # handler for that version and returns an instance of it.
82 def makeVersion(version
=DEVEL
):
83 """Return a new instance of the syntax handler for version. version can be
84 either a string or the matching constant. This function is useful for
85 standalone programs which just need to handle a specific version of
86 kickstart syntax (as provided by a command line argument, for example)
87 and need to instantiate the correct object.
89 super = returnClassForVersion(version
)