本文整理汇总了Python中pykickstart.parser.Packages类的典型用法代码示例。如果您正苦于以下问题:Python Packages类的具体用法?Python Packages怎么用?Python Packages使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Packages类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTest
def runTest(self):
pkgs = Packages()
pkgs.default = True
pkgs.multiLib = True
self.assertEqual("""%packages --default --multilib
%end""", str(pkgs).strip())
示例2: runTest
def runTest(self):
DevelPackagesBase.runTest(self)
pkgs = Packages()
pkgs.default = True
pkgs.excludeWeakdeps = True
self.assertEqual("""%packages --default --excludeWeakdeps
%end""", str(pkgs).strip())
示例3: __init__
def __init__(self, mapping=None, dataMapping=None, commandUpdates=None,
dataUpdates=None, *args, **kwargs):
"""Create a new BaseHandler instance. This method must be provided by
all subclasses, but subclasses must call BaseHandler.__init__ first.
mapping -- A custom map from command strings to classes,
useful when creating your own handler with
special command objects. It is otherwise unused
and rarely needed. If you give this argument,
the mapping takes the place of the default one
and so must include all commands you want
recognized.
dataMapping -- This is the same as mapping, but for data
objects. All the same comments apply.
commandUpdates -- This is similar to mapping, but does not take
the place of the defaults entirely. Instead,
this mapping is applied after the defaults and
updates it with just the commands you want to
modify.
dataUpdates -- This is the same as commandUpdates, but for
data objects.
Instance attributes:
packages -- An instance of pykickstart.parser.Packages which
describes the packages section of the input file.
platform -- A string describing the hardware platform, which is
needed only by system-config-kickstart.
scripts -- A list of pykickstart.parser.Script instances, which is
populated by KickstartParser.addScript and describes the
%pre/%pre-install/%post/%traceback script section of the
input file.
"""
# We don't want people using this class by itself.
if self.__class__ is BaseHandler:
raise TypeError("BaseHandler is an abstract class.")
KickstartHandler.__init__(self, *args, **kwargs)
# This isn't really a good place for these, but it's better than
# everything else I can think of.
self.scripts = []
self.packages = Packages()
self.platform = ""
# Any sections that we do not understand but want to prevent causing errors
# are represented by a NullSection. We want to preserve those on output, so
# keep a list of their string representations here. This is likely to change
# in the future. Don't rely on this exact implementation.
self._null_section_strings = []
self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates)
示例4: __init__
def __init__(self, mapping=None, dataMapping=None, commandUpdates=None,
dataUpdates=None, *args, **kwargs):
"""Create a new BaseHandler instance. This method must be provided by
all subclasses, but subclasses must call BaseHandler.__init__ first.
mapping -- A custom map from command strings to classes,
useful when creating your own handler with
special command objects. It is otherwise unused
and rarely needed. If you give this argument,
the mapping takes the place of the default one
and so must include all commands you want
recognized.
dataMapping -- This is the same as mapping, but for data
objects. All the same comments apply.
commandUpdates -- This is similar to mapping, but does not take
the place of the defaults entirely. Instead,
this mapping is applied after the defaults and
updates it with just the commands you want to
modify.
dataUpdates -- This is the same as commandUpdates, but for
data objects.
Instance attributes:
commands -- A mapping from a string command to a KickstartCommand
subclass object that handles it. Multiple strings can
map to the same object, but only one instance of the
command object should ever exist. Most users should
never have to deal with this directly, as it is
manipulated internally and called through dispatcher.
currentLine -- The current unprocessed line from the input file
that caused this handler to be run.
packages -- An instance of pykickstart.parser.Packages which
describes the packages section of the input file.
platform -- A string describing the hardware platform, which is
needed only by system-config-kickstart.
scripts -- A list of pykickstart.parser.Script instances, which is
populated by KickstartParser.addScript and describes the
%pre/%pre-install/%post/%traceback script section of the
input file.
"""
# We don't want people using this class by itself.
if self.__class__ is BaseHandler:
raise TypeError("BaseHandler is an abstract class.")
KickstartObject.__init__(self, *args, **kwargs)
# This isn't really a good place for these, but it's better than
# everything else I can think of.
self.scripts = []
self.packages = Packages()
self.platform = ""
# These will be set by the dispatcher.
self.commands = {}
self.currentLine = ""
# A dict keyed by an integer priority number, with each value being a
# list of KickstartCommand subclasses. This dict is maintained by
# registerCommand and used in __str__. No one else should be touching
# it.
self._writeOrder = {}
self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates)
示例5: BaseHandler
class BaseHandler(KickstartObject):
"""Each version of kickstart syntax is provided by a subclass of this
class. These subclasses are what users will interact with for parsing,
extracting data, and writing out kickstart files. This is an abstract
class.
version -- The version this syntax handler supports. This is set by
a class attribute of a BaseHandler subclass and is used to
set up the command dict. It is for read-only use.
"""
version = None
def __init__(self, mapping=None, dataMapping=None, commandUpdates=None,
dataUpdates=None, *args, **kwargs):
"""Create a new BaseHandler instance. This method must be provided by
all subclasses, but subclasses must call BaseHandler.__init__ first.
mapping -- A custom map from command strings to classes,
useful when creating your own handler with
special command objects. It is otherwise unused
and rarely needed. If you give this argument,
the mapping takes the place of the default one
and so must include all commands you want
recognized.
dataMapping -- This is the same as mapping, but for data
objects. All the same comments apply.
commandUpdates -- This is similar to mapping, but does not take
the place of the defaults entirely. Instead,
this mapping is applied after the defaults and
updates it with just the commands you want to
modify.
dataUpdates -- This is the same as commandUpdates, but for
data objects.
Instance attributes:
commands -- A mapping from a string command to a KickstartCommand
subclass object that handles it. Multiple strings can
map to the same object, but only one instance of the
command object should ever exist. Most users should
never have to deal with this directly, as it is
manipulated internally and called through dispatcher.
currentLine -- The current unprocessed line from the input file
that caused this handler to be run.
packages -- An instance of pykickstart.parser.Packages which
describes the packages section of the input file.
platform -- A string describing the hardware platform, which is
needed only by system-config-kickstart.
scripts -- A list of pykickstart.parser.Script instances, which is
populated by KickstartParser.addScript and describes the
%pre/%pre-install/%post/%traceback script section of the
input file.
"""
# We don't want people using this class by itself.
if self.__class__ is BaseHandler:
raise TypeError("BaseHandler is an abstract class.")
KickstartObject.__init__(self, *args, **kwargs)
# This isn't really a good place for these, but it's better than
# everything else I can think of.
self.scripts = []
self.packages = Packages()
self.platform = ""
# These will be set by the dispatcher.
self.commands = {}
self.currentLine = ""
# A dict keyed by an integer priority number, with each value being a
# list of KickstartCommand subclasses. This dict is maintained by
# registerCommand and used in __str__. No one else should be touching
# it.
self._writeOrder = {}
self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates)
def __str__(self):
"""Return a string formatted for output to a kickstart file."""
retval = ""
if self.platform != "":
retval += "#platform=%s\n" % self.platform
retval += "#version=%s\n" % versionToString(self.version)
lst = list(self._writeOrder.keys())
lst.sort()
for prio in lst:
for obj in self._writeOrder[prio]:
obj_str = obj.__str__()
if isinstance(obj_str, six.text_type) and not six.PY3:
obj_str = obj_str.encode("utf-8")
retval += obj_str
for script in self.scripts:
script_str = script.__str__()
#.........这里部分代码省略.........
示例6: BaseHandler
class BaseHandler(KickstartHandler):
"""A base kickstart handler.
Each version of kickstart syntax is provided by a subclass of this
class. These subclasses are what users will interact with for parsing,
extracting data, and writing out kickstart files. This is an abstract
class.
"""
def __init__(self, mapping=None, dataMapping=None, commandUpdates=None,
dataUpdates=None, *args, **kwargs):
"""Create a new BaseHandler instance. This method must be provided by
all subclasses, but subclasses must call BaseHandler.__init__ first.
mapping -- A custom map from command strings to classes,
useful when creating your own handler with
special command objects. It is otherwise unused
and rarely needed. If you give this argument,
the mapping takes the place of the default one
and so must include all commands you want
recognized.
dataMapping -- This is the same as mapping, but for data
objects. All the same comments apply.
commandUpdates -- This is similar to mapping, but does not take
the place of the defaults entirely. Instead,
this mapping is applied after the defaults and
updates it with just the commands you want to
modify.
dataUpdates -- This is the same as commandUpdates, but for
data objects.
Instance attributes:
packages -- An instance of pykickstart.parser.Packages which
describes the packages section of the input file.
platform -- A string describing the hardware platform, which is
needed only by system-config-kickstart.
scripts -- A list of pykickstart.parser.Script instances, which is
populated by KickstartParser.addScript and describes the
%pre/%pre-install/%post/%traceback script section of the
input file.
"""
# We don't want people using this class by itself.
if self.__class__ is BaseHandler:
raise TypeError("BaseHandler is an abstract class.")
KickstartHandler.__init__(self, *args, **kwargs)
# This isn't really a good place for these, but it's better than
# everything else I can think of.
self.scripts = []
self.packages = Packages()
self.platform = ""
# Any sections that we do not understand but want to prevent causing errors
# are represented by a NullSection. We want to preserve those on output, so
# keep a list of their string representations here. This is likely to change
# in the future. Don't rely on this exact implementation.
self._null_section_strings = []
self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates)
def __str__(self):
"""Return a string formatted for output to a kickstart file."""
retval = ""
if self.platform:
retval += "#platform=%s\n" % self.platform
retval += "#version=%s\n" % versionToString(self.version)
retval += KickstartHandler.__str__(self)
for script in self.scripts:
script_str = script.__str__()
if isinstance(script_str, six.text_type) and not six.PY3:
script_str = script_str.encode("utf-8")
retval += script_str
if self._null_section_strings:
retval += "\n"
for s in self._null_section_strings:
retval += s
retval += self.packages.__str__()
return retval
def _registerCommands(self, mapping=None, dataMapping=None, commandUpdates=None,
dataUpdates=None):
if mapping == {} or mapping is None:
from pykickstart.handlers.control import commandMap
cMap = commandMap[self.version]
else:
cMap = mapping
if dataMapping == {} or dataMapping is None:
#.........这里部分代码省略.........