当前位置: 首页>>代码示例>>Python>>正文


Python configparser.RawConfigParser方法代码示例

本文整理汇总了Python中six.moves.configparser.RawConfigParser方法的典型用法代码示例。如果您正苦于以下问题:Python configparser.RawConfigParser方法的具体用法?Python configparser.RawConfigParser怎么用?Python configparser.RawConfigParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.configparser的用法示例。


在下文中一共展示了configparser.RawConfigParser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def setUp(self):
        super(TestNotifications, self).setUp()
        config = configparser.RawConfigParser()
        config.read("projects.ini")
        config.set('DEFAULT', 'datadir', tempfile.mkdtemp())
        config.set('DEFAULT', 'scriptsdir', tempfile.mkdtemp())
        config.set('DEFAULT', 'baseurl', "file://%s" % config.get('DEFAULT',
                                                                  'datadir'))

        self.config = ConfigOptions(config)
        self.commit = db.Commit(dt_commit=123, project_name='foo',
                                commit_hash='1c67b1ab8c6fe273d4e175a14f0df5'
                                            'd3cbbd0edf',
                                repo_dir='/home/dlrn/data/foo',
                                distro_hash='c31d1b18eb5ab5aed6721fc4fad06c9'
                                            'bd242490f',
                                dt_distro=123,
                                distgit_dir='/home/dlrn/data/foo_distro',
                                commit_branch='master', dt_build=1441245153)
        self.packages = [{'upstream': 'https://github.com/openstack/foo',
                          'name': 'foo', 'maintainers': ['test@test.com'],
                          'master-distgit':
                          'https://github.com/rdo-packages/foo-distgit.git'}] 
开发者ID:softwarefactory-project,项目名称:DLRN,代码行数:25,代码来源:test_notifications.py

示例2: setUp

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def setUp(self):
        super(TestProcessBuildResult, self).setUp()
        config = configparser.RawConfigParser()
        config.read("projects.ini")
        config.set('DEFAULT', 'datadir', tempfile.mkdtemp())
        config.set('DEFAULT', 'scriptsdir', tempfile.mkdtemp())
        config.set('DEFAULT', 'baseurl', "file://%s" % config.get('DEFAULT',
                                                                  'datadir'))
        self.config = ConfigOptions(config)
        self.commit = db.Commit(dt_commit=123, project_name='foo', type="rpm",
                                commit_hash='1c67b1ab8c6fe273d4e175a14f0df5'
                                            'd3cbbd0edf',
                                repo_dir='/home/dlrn/data/foo',
                                distro_hash='c31d1b18eb5ab5aed6721fc4fad06c9'
                                            'bd242490f',
                                dt_distro=123,
                                distgit_dir='/home/dlrn/data/foo_distro',
                                commit_branch='master', dt_build=1441245153)
        self.db_fd, filepath = tempfile.mkstemp()
        self.session = mocked_session("sqlite:///%s" % filepath)
        self.packages = [{'upstream': 'https://github.com/openstack/foo',
                          'name': 'foo', 'maintainers': 'test@test.com'},
                         {'upstream': 'https://github.com/openstack/test',
                          'name': 'test', 'maintainers': 'test@test.com'}] 
开发者ID:softwarefactory-project,项目名称:DLRN,代码行数:26,代码来源:test_shell.py

示例3: test_clone_no_fallback

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def test_clone_no_fallback(self, sh_mock):
        config = configparser.RawConfigParser()
        config.read("projects.ini")
        config.set('DEFAULT', 'fallback_to_master', '0')
        self.config = ConfigOptions(config)
        # We need to redefine the mock object again, to use a side effect
        # that will fail in the git checkout call. A bit convoluted, but
        # it works
        with mock.patch.object(sh.Command, '__call__') as new_mock:
            new_mock.side_effect = _aux_sh
            self.assertRaises(sh.ErrorReturnCode_1, repositories.refreshrepo,
                              'url', 'path', branch='branch')
            expected = [mock.call('url', 'path'),
                        mock.call('origin'),
                        mock.call('-f', 'branch')]
            self.assertEqual(new_mock.call_args_list, expected) 
开发者ID:softwarefactory-project,项目名称:DLRN,代码行数:18,代码来源:test_repositories.py

示例4: test_clone_fallback_var

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def test_clone_fallback_var(self, sh_mock):
        config = configparser.RawConfigParser()
        config.read("projects.ini")
        config.set('DEFAULT', 'fallback_to_master', '1')
        config.set('DEFAULT', 'nonfallback_branches', '^foo-')
        self.config = ConfigOptions(config)
        with mock.patch.object(sh.Command, '__call__') as new_mock:
            new_mock.side_effect = _aux_sh
            result = repositories.refreshrepo('url', 'path', branch='bar')
            self.assertEqual(result, ['master', 'None'])
            expected = [mock.call('url', 'path'),
                        mock.call('origin'),
                        mock.call('-f', 'bar'),
                        mock.call('master'),
                        mock.call('--hard', 'origin/master'),
                        mock.call('--pretty=format:%H %ct', '-1', '.')]
            self.assertEqual(new_mock.call_args_list, expected) 
开发者ID:softwarefactory-project,项目名称:DLRN,代码行数:19,代码来源:test_repositories.py

示例5: test_detect_dirs

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def test_detect_dirs(self):
        self.config = configparser.RawConfigParser()
        self.config.read("samples/projects.ini.detect")
        config = ConfigOptions(self.config)
        self.assertEqual(
            config.datadir,
            os.path.realpath(os.path.join(
                             os.path.dirname(os.path.abspath(__file__)),
                             "../../data")))
        self.assertEqual(
            config.templatedir,
            os.path.realpath(os.path.join(
                             os.path.dirname(os.path.abspath(__file__)),
                             "../templates")))
        self.assertEqual(
            config.scriptsdir,
            os.path.realpath(os.path.join(
                             os.path.dirname(os.path.abspath(__file__)),
                             "../../scripts"))) 
开发者ID:softwarefactory-project,项目名称:DLRN,代码行数:21,代码来源:test_config.py

示例6: setUp

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def setUp(self):
        super(TestBuild, self).setUp()
        self.configfile = configparser.RawConfigParser()
        self.configfile.read("projects.ini")
        self.configfile.set('DEFAULT', 'datadir', tempfile.mkdtemp())
        self.configfile.set('DEFAULT', 'scriptsdir', tempfile.mkdtemp())
        self.configfile.set('DEFAULT', 'baseurl', "file://%s" %
                            self.configfile.get('DEFAULT', 'datadir'))
        self.config = ConfigOptions(self.configfile)
        shutil.copyfile(os.path.join("scripts", "centos.cfg"),
                        os.path.join(self.config.scriptsdir, "centos.cfg"))
        with open(os.path.join(self.config.datadir,
                  "delorean-deps.repo"), "w") as fp:
            fp.write("[test]\nname=test\nenabled=0\n")
        self.db_fd, filepath = tempfile.mkstemp()
        self.session = db.getSession("sqlite:///%s" % filepath)
        utils.loadYAML(self.session, './dlrn/tests/samples/commits_1.yaml') 
开发者ID:softwarefactory-project,项目名称:DLRN,代码行数:19,代码来源:test_build.py

示例7: _load_configuration

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def _load_configuration():
    """Attempt to load settings from various praw.ini files."""
    config = configparser.RawConfigParser()
    module_dir = os.path.dirname(sys.modules[__name__].__file__)
    if 'APPDATA' in os.environ:  # Windows
        os_config_path = os.environ['APPDATA']
    elif 'XDG_CONFIG_HOME' in os.environ:  # Modern Linux
        os_config_path = os.environ['XDG_CONFIG_HOME']
    elif 'HOME' in os.environ:  # Legacy Linux
        os_config_path = os.path.join(os.environ['HOME'], '.config')
    else:
        os_config_path = None
    locations = [os.path.join(module_dir, 'praw.ini'), 'praw.ini']
    if os_config_path is not None:
        locations.insert(1, os.path.join(os_config_path, 'praw.ini'))
    if not config.read(locations):
        raise Exception('Could not find config file in any of: {0}'
                        .format(locations))
    return config 
开发者ID:tildeclub,项目名称:ttrv,代码行数:21,代码来源:settings.py

示例8: parse_configuration_file

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def parse_configuration_file(self, modelFileName):

        config = ConfigParser()
        config.optionxform = str
        config.read(modelFileName)

        # all sections provided in the configuration/ini file
        self.allSections = config.sections()

        # read all sections 
        for sec in self.allSections:
            vars(self)[sec] = {}                               # example: to instantiate self.globalOptions 
            options = config.options(sec)                      # example: logFileDir
            for opt in options:
                val = config.get(sec, opt)                     # value defined in every option 
                self.__getattribute__(sec)[opt] = val          # example: self.globalOptions['logFileDir'] = val 
开发者ID:UU-Hydro,项目名称:PCR-GLOBWB_model,代码行数:18,代码来源:configuration.py

示例9: parse_configuration_file

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def parse_configuration_file(self, modelFileName):

        config = ConfigParser()
        config.optionxform = str
        config.read(modelFileName)

        # all sections provided in the configuration/ini file
        self.allSections  = config.sections()
        
        # read all sections 
        for sec in self.allSections:
            vars(self)[sec] = {}                               # example: to instantiate self.globalOptions 
            options = config.options(sec)                      # example: logFileDir
            for opt in options:
                val = config.get(sec, opt)                     # value defined in every option 
                self.__getattribute__(sec)[opt] = val          # example: self.globalOptions['logFileDir'] = val 
开发者ID:UU-Hydro,项目名称:PCR-GLOBWB_model,代码行数:18,代码来源:configuration_for_modflow.py

示例10: __init__

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def __init__(self, aws_key=None, aws_secret=None, 
            from_env=False, 
            from_config=False,
            config_filename='~/.aws/credentials',
            env_secret_key='AWS_ACCESS_SECRET',
            env_key='AWS_ACCESS_KEY'):
        self.key = aws_key
        self.secret = aws_secret
        self.from_env=from_env
        if from_env:
            self.key = os.environ.get(env_key)
            self.secret = os.environ.get(env_secret_key)
        if from_config:
            with open(os.path.expanduser(config_filename)) as f:
                sample_config = f.read()
            config = configparser.RawConfigParser(allow_no_value=True)
            config.read_string(sample_config)
            self.key = config.get('default', 'aws_access_key_id')
            self.secret = config.get('default', 'aws_secret_access_key') 
开发者ID:justinjfu,项目名称:doodad,代码行数:21,代码来源:ec2.py

示例11: validate_from_file

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def validate_from_file(cls, yaml_file=None):
        config = configparser.RawConfigParser()
        config.read(yaml_file)
        config_dict = cls._convert_config_to_dict(config)

        for section, option_details in cls.ANSIBLE_CONFIG_OPTIONS.items():
            for opt_name, opt_params in option_details.items():
                try:
                    config_value = config_dict[section][opt_name]
                    cls._validate_config_option(yaml_file,
                                                opt_name,
                                                opt_params['type'],
                                                opt_params['comparison'],
                                                opt_params['expected_value'],
                                                config_value,
                                                opt_params['critical'])
                except KeyError:
                    cls._handle_missing_value(yaml_file, section, opt_name,
                                              opt_params['expected_value'],
                                              opt_params['critical']) 
开发者ID:redhat-openstack,项目名称:infrared,代码行数:22,代码来源:validators.py

示例12: filter_factory

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def filter_factory(global_conf, **local_conf):
    conf = global_conf.copy()
    conf.update(local_conf)

    module_name = conf.get('storlet_gateway_module', 'stub')
    gateway_class = load_gateway(module_name)
    conf['gateway_module'] = gateway_class

    configParser = ConfigParser.RawConfigParser()
    configParser.read(conf.get('storlet_gateway_conf',
                               '/etc/swift/storlet_stub_gateway.conf'))
    gateway_conf = dict(configParser.items("DEFAULT"))

    # TODO(eranr): Add supported storlets languages and
    #  supported storlet API version
    containers = get_container_names(conf)
    swift_info = {'storlet_container': containers['storlet'],
                  'storlet_dependency': containers['dependency'],
                  'storlet_gateway_class': gateway_class.__name__}
    register_swift_info('storlet_handler', False, **swift_info)

    def storlet_handler_filter(app):
        return StorletHandlerMiddleware(app, conf, gateway_conf)
    return storlet_handler_filter 
开发者ID:openstack,项目名称:storlets,代码行数:26,代码来源:storlet_handler.py

示例13: show_config

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def show_config(config):
    parser = configparser.RawConfigParser()

    if not config.envlist_explicit or reporter.verbosity() >= reporter.Verbosity.INFO:
        tox_info(config, parser)
        version_info(parser)
    tox_envs_info(config, parser)

    content = StringIO()
    parser.write(content)
    value = content.getvalue().rstrip()
    reporter.verbosity0(value) 
开发者ID:tox-dev,项目名称:tox,代码行数:14,代码来源:show_config.py

示例14: __init__

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def __init__(self):
        """
        Load from ~/.pypirc
        """
        defaults = dict.fromkeys(['username', 'password', 'repository'], '')
        configparser.RawConfigParser.__init__(self, defaults)

        rc = os.path.join(os.path.expanduser('~'), '.pypirc')
        if os.path.exists(rc):
            self.read(rc) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:package_index.py

示例15: extract_wininst_cfg

# 需要导入模块: from six.moves import configparser [as 别名]
# 或者: from six.moves.configparser import RawConfigParser [as 别名]
def extract_wininst_cfg(dist_filename):
    """Extract configuration data from a bdist_wininst .exe

    Returns a configparser.RawConfigParser, or None
    """
    f = open(dist_filename, 'rb')
    try:
        endrec = zipfile._EndRecData(f)
        if endrec is None:
            return None

        prepended = (endrec[9] - endrec[5]) - endrec[6]
        if prepended < 12:  # no wininst data here
            return None
        f.seek(prepended - 12)

        tag, cfglen, bmlen = struct.unpack("<iii", f.read(12))
        if tag not in (0x1234567A, 0x1234567B):
            return None  # not a valid tag

        f.seek(prepended - (12 + cfglen))
        init = {'version': '', 'target_version': ''}
        cfg = configparser.RawConfigParser(init)
        try:
            part = f.read(cfglen)
            # Read up to the first null byte.
            config = part.split(b'\0', 1)[0]
            # Now the config is in bytes, but for RawConfigParser, it should
            #  be text, so decode it.
            config = config.decode(sys.getfilesystemencoding())
            cfg.readfp(six.StringIO(config))
        except configparser.Error:
            return None
        if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
            return None
        return cfg

    finally:
        f.close() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:41,代码来源:easy_install.py


注:本文中的six.moves.configparser.RawConfigParser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。