本文整理汇总了Python中iniparse.compat.RawConfigParser类的典型用法代码示例。如果您正苦于以下问题:Python RawConfigParser类的具体用法?Python RawConfigParser怎么用?Python RawConfigParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RawConfigParser类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readVersionGroupsConfig
def readVersionGroupsConfig(configfile="/etc/yum/version-groups.conf"):
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
try:
parser.readfp(confpp_obj)
except ParsingError, e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
示例2: readStartupConfig
def readStartupConfig(configfile, root, releasever=None):
"""Parse Yum's main configuration file and return a
:class:`StartupConf` instance. This is required in order to
access configuration settings required as Yum starts up.
:param configfile: the path to yum.conf
:param root: the base path to use for installation (typically '/')
:return: A :class:`StartupConf` instance
:raises: :class:`Errors.ConfigError` if a problem is detected with while parsing.
"""
# ' xemacs syntax hack
StartupConf.installroot.default = root
startupconf = StartupConf()
startupconf.config_file_path = configfile
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
yumvars = _getEnvVar()
_read_yumvars(yumvars, startupconf.installroot)
confpp_obj._vars = yumvars
startupconf.yumvars = yumvars
try:
parser.readfp(confpp_obj)
except ParsingError, e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
示例3: readStartupConfig
def readStartupConfig(configfile, root):
'''
Parse Yum's main configuration file and return a StartupConf instance.
This is required in order to access configuration settings required as Yum
starts up.
@param configfile: The path to yum.conf.
@param root: The base path to use for installation (typically '/')
@return: A StartupConf instance.
May raise Errors.ConfigError if a problem is detected with while parsing.
'''
# ' xemacs syntax hack
StartupConf.installroot.default = root
startupconf = StartupConf()
startupconf.config_file_path = configfile
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
try:
parser.readfp(confpp_obj)
except ParsingError, e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
示例4: readStartupConfig
def readStartupConfig(configfile, root):
"""Parse Yum's main configuration file and return a
:class:`StartupConf` instance. This is required in order to
access configuration settings required as Yum starts up.
:param configfile: the path to yum.conf
:param root: the base path to use for installation (typically '/')
:return: A :class:`StartupConf` instance
:raises: :class:`dnf.exceptions.ConfigError` if a problem is detected with while parsing.
"""
StartupConf.installroot.default = root
startupconf = StartupConf()
startupconf.config_file_path = configfile
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
try:
parser.readfp(confpp_obj)
except ParsingError as e:
raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
startupconf.populate(parser, 'main')
# Check that plugin paths are all absolute
for path in startupconf.pluginpath:
if not path[0] == '/':
raise dnf.exceptions.ConfigError("All plugin search paths must be absolute")
# Stuff this here to avoid later re-parsing
startupconf._parser = parser
return startupconf
示例5: readVersionGroupsConfig
def readVersionGroupsConfig(configfile="/etc/yum/version-groups.conf"):
"""Parse the configuration file for version groups.
:param configfile: the configuration file to read
:return: a dictionary containing the parsed options
"""
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
try:
parser.readfp(confpp_obj)
except ParsingError, e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
示例6: read
def read(self, filename=None):
# :api
if filename is None:
filename = self.config_file_path
parser = ConfigParser()
config_pp = ConfigPreProcessor(filename)
try:
parser.readfp(config_pp)
except ParsingError as e:
raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
self.populate(parser, 'main')
# update to where we read the file from
self.config_file_path = filename
示例7: readVersionGroupsConfig
def readVersionGroupsConfig(configfile="/etc/yum/version-groups.conf"):
"""Parse the configuration file for version groups.
:param configfile: the configuration file to read
:return: a dictionary containing the parsed options
"""
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
try:
parser.readfp(confpp_obj)
except ParsingError as e:
raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
ret = {}
for section in parser.sections():
ret[section] = VersionGroupConf()
ret[section].populate(parser, section)
return ret
示例8: readStartupConfig
def readStartupConfig(configfile, root):
"""Parse Yum's main configuration file and return a
:class:`StartupConf` instance. This is required in order to
access configuration settings required as Yum starts up.
:param configfile: the path to yum.conf
:param root: the base path to use for installation (typically '/')
:return: A :class:`StartupConf` instance
:raises: :class:`dnf.exceptions.ConfigError` if a problem is detected with while parsing.
"""
StartupConf.installroot.default = root
startupconf = StartupConf()
startupconf.config_file_path = configfile
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
try:
parser.readfp(confpp_obj)
except ParsingError, e:
raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
示例9: read
def read(self, filename=None, priority=PRIO_DEFAULT):
# :api
if filename is None:
filename = self._get_value('config_file_path')
self._parser = ConfigParser()
config_pp = dnf.conf.parser.ConfigPreProcessor(filename)
try:
self._parser.readfp(config_pp)
except ParsingError as e:
raise dnf.exceptions.ConfigError("Parsing file failed: %s" % e)
self._populate(self._parser, self._section, filename, priority)
# update to where we read the file from
self._set_value('config_file_path', filename, priority)
示例10: MainConf
class MainConf(BaseConfig):
# :api
"""Configuration option definitions for dnf.conf's [main] section."""
def __init__(self, section='main', parser=None):
# pylint: disable=R0915
super(MainConf, self).__init__(section, parser)
self.substitutions = dnf.conf.substitutions.Substitutions()
self.arch = hawkey.detect_arch()
# setup different cache and log for non-priviledged users
if dnf.util.am_i_root():
cachedir = dnf.const.SYSTEM_CACHEDIR
logdir = '/var/log'
else:
try:
cachedir = logdir = misc.getCacheDir()
except (IOError, OSError) as e:
logger.critical(_('Could not set cachedir: %s'), ucd(e))
self._add_option('debuglevel',
IntOption(2, range_min=0, range_max=10)) # :api
self._add_option('errorlevel', IntOption(2, range_min=0, range_max=10))
self._add_option('installroot', PathOption('/', abspath=True)) # :api
self._add_option('config_file_path',
PathOption(dnf.const.CONF_FILENAME)) # :api
self._add_option('plugins', BoolOption(True))
self._add_option('pluginpath', ListOption([dnf.const.PLUGINPATH])) # :api
self._add_option('pluginconfpath',
ListOption([dnf.const.PLUGINCONFPATH])) # :api
self._add_option('persistdir', PathOption(dnf.const.PERSISTDIR)) # :api
self._add_option('transformdb', BoolOption(True)) # :api
self._add_option('recent', IntOption(7, range_min=0))
self._add_option('retries', PositiveIntOption(10, names_of_0=["0"]))
self._add_option('reset_nice', BoolOption(True))
self._add_option('cachedir', PathOption(cachedir)) # :api
self._add_option('system_cachedir',
PathOption(dnf.const.SYSTEM_CACHEDIR)) # :api
self._add_option('cacheonly', BoolOption(False))
self._add_option('keepcache', BoolOption(False))
self._add_option('logdir', Option(logdir)) # :api
self._add_option('reposdir', ListOption(['/etc/yum.repos.d',
'/etc/yum/repos.d',
'/etc/distro.repos.d'])) # :api
self._add_option('debug_solver', BoolOption(False))
self._add_option('excludepkgs', ListAppendOption())
self._add_option('includepkgs', ListAppendOption())
self._add_option('exclude', self._get_option('excludepkgs'))
# ^ compatibility with yum
self._add_option('fastestmirror', BoolOption(False))
self._add_option('proxy', UrlOption(schemes=('http', 'ftp', 'https',
'socks5', 'socks5h',
'socks4', 'socks4a'),
allow_none=True)) # :api
self._add_option('proxy_username', Option()) # :api
self._add_option('proxy_password', Option()) # :api
self._add_option('protected_packages',
ListOption("dnf glob:/etc/yum/protected.d/*.conf " \
"glob:/etc/dnf/protected.d/*.conf")) #:api
self._add_option('username', Option()) # :api
self._add_option('password', Option()) # :api
self._add_option('installonlypkgs', ListAppendOption(dnf.const.INSTALLONLYPKGS))
self._add_option('group_package_types', ListOption(dnf.const.GROUP_PACKAGE_TYPES))
# NOTE: If you set this to 2, then because it keeps the current
# kernel it means if you ever install an "old" kernel it'll get rid
# of the newest one so you probably want to use 3 as a minimum
# ... if you turn it on.
self._add_option('installonly_limit',
PositiveIntOption(3, range_min=2, names_of_0=["0", "<off>"])) # :api
self._add_option('tsflags', ListAppendOption()) # :api
self._add_option('assumeyes', BoolOption(False)) # :api
self._add_option('assumeno', BoolOption(False))
self._add_option('check_config_file_age', BoolOption(True))
self._add_option('defaultyes', BoolOption(False))
self._add_option('diskspacecheck', BoolOption(True))
self._add_option('gpgcheck', BoolOption(False))
self._add_option('repo_gpgcheck', BoolOption(False))
self._add_option('localpkg_gpgcheck', BoolOption(False))
self._add_option('obsoletes', BoolOption(True))
self._add_option('showdupesfromrepos', BoolOption(False))
self._add_option('enabled', BoolOption(True))
self._add_option('enablegroups', BoolOption(True))
self._add_option('exit_on_lock', BoolOption(False))
self._add_option('bandwidth', BytesOption(0))
self._add_option('minrate', BytesOption(1000))
self._add_option('ip_resolve',
CaselessSelectionOption(choices=('ipv4', 'ipv6',
'whatever'),
mapper={'4': 'ipv4',
'6': 'ipv6'}))
self._add_option('throttle', ThrottleOption(0))
self._add_option('timeout', SecondsOption(30))
self._add_option('max_parallel_downloads', IntOption(None, range_min=1))
#.........这里部分代码省略.........