當前位置: 首頁>>代碼示例>>Python>>正文


Python RawConfigParser.readfp方法代碼示例

本文整理匯總了Python中iniparse.compat.RawConfigParser.readfp方法的典型用法代碼示例。如果您正苦於以下問題:Python RawConfigParser.readfp方法的具體用法?Python RawConfigParser.readfp怎麽用?Python RawConfigParser.readfp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iniparse.compat.RawConfigParser的用法示例。


在下文中一共展示了RawConfigParser.readfp方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: readStartupConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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)
開發者ID:balagopalraj,項目名稱:clearlinux,代碼行數:27,代碼來源:config.py

示例2: readVersionGroupsConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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)
開發者ID:balagopalraj,項目名稱:clearlinux,代碼行數:9,代碼來源:config.py

示例3: readStartupConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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)
開發者ID:harshithanaik,項目名稱:yum,代碼行數:31,代碼來源:config.py

示例4: readStartupConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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
開發者ID:lmacken,項目名稱:dnf,代碼行數:32,代碼來源:config.py

示例5: readVersionGroupsConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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)
開發者ID:harshithanaik,項目名稱:yum,代碼行數:15,代碼來源:config.py

示例6: read

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
    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
開發者ID:DNIWE-Systems,項目名稱:dnf,代碼行數:16,代碼來源:config.py

示例7: readVersionGroupsConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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
開發者ID:lmacken,項目名稱:dnf,代碼行數:20,代碼來源:config.py

示例8: readStartupConfig

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]
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)
開發者ID:ryanuber,項目名稱:dnf,代碼行數:23,代碼來源:config.py

示例9: MainConf

# 需要導入模塊: from iniparse.compat import RawConfigParser [as 別名]
# 或者: from iniparse.compat.RawConfigParser import readfp [as 別名]

#.........這裏部分代碼省略.........
        if hasattr(opts, 'main_setopts'):
            # now set all the non-first-start opts from main from our setopts
            # pylint: disable=W0212
            for name, val in opts.main_setopts._get_kwargs():
                opt = self._get_option(name)
                if opt:
                    opt._set(val, dnf.conf.PRIO_COMMANDLINE)
                elif hasattr(self, name):
                    setattr(self, name, val)
                else:
                    msg = "Main config did not have a %s attr. before setopt"
                    logger.warning(msg, name)

    def exclude_pkgs(self, pkgs):
        # :api
        name = "excludepkgs"

        if pkgs is not None and pkgs != []:
            confopt = self._get_option(name)
            if confopt:
                confopt._set(pkgs, dnf.conf.PRIO_COMMANDLINE)
            else:
                logger.warning(_('Unknown configuration option: %s = %s'),
                               ucd(name), ucd(pkgs))

    def _adjust_conf_options(self):
        """Adjust conf options interactions"""

        skip_broken = self._get_option('skip_broken')
        skip_broken_val = skip_broken._get()
        if skip_broken_val:
            strict = self._get_option('strict')
            strict._set(not skip_broken_val, skip_broken._get_priority())

    @property
    def releasever(self):
        # :api
        return self.substitutions.get('releasever')

    @releasever.setter
    def releasever(self, val):
        # :api
        if val is None:
            self.substitutions.pop('releasever', None)
            return
        self.substitutions['releasever'] = val

    @property
    def arch(self):
        # :api
        return self.substitutions.get('arch')

    @arch.setter
    def arch(self, val):
        # :api

        if val is None:
            self.substitutions.pop('arch', None)
            return
        if val not in dnf.rpm._BASEARCH_MAP.keys():
            msg = _('Incorrect or unknown "{}": {}')
            raise dnf.exceptions.Error(msg.format("arch", val))
        self.substitutions['arch'] = val
        self.basearch = dnf.rpm.basearch(val)

    @property
    def basearch(self):
        # :api
        return self.substitutions.get('basearch')

    @basearch.setter
    def basearch(self, val):
        # :api

        if val is None:
            self.substitutions.pop('basearch', None)
            return
        if val not in dnf.rpm._BASEARCH_MAP.values():
            msg = _('Incorrect or unknown "{}": {}')
            raise dnf.exceptions.Error(msg.format("basearch", val))
        self.substitutions['basearch'] = val

    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)

    @property
    def verbose(self):
        return self._get_value('debuglevel') >= dnf.const.VERBOSE_LEVEL
開發者ID:edynox,項目名稱:dnf,代碼行數:104,代碼來源:config.py


注:本文中的iniparse.compat.RawConfigParser.readfp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。