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


Python LintConfig.apply_config_options方法代码示例

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


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

示例1: test_apply_config_options_negative

# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import apply_config_options [as 别名]
    def test_apply_config_options_negative(self):
        config = LintConfig()

        # assert error on incorrect rule
        with self.assertRaisesRegexp(LintConfigError, "No such rule 'foo'"):
            config.apply_config_options(['foo.bar=1'])

        # no equal sign
        expected_msg = "'foo.bar' is an invalid configuration option. Use '<rule>.<option>=<value>'"
        with self.assertRaisesRegexp(LintConfigError, expected_msg):
            config.apply_config_options(['foo.bar'])

        # missing value
        expected_msg = "'foo.bar=' is an invalid configuration option. Use '<rule>.<option>=<value>'"
        with self.assertRaisesRegexp(LintConfigError, expected_msg):
            config.apply_config_options(['foo.bar='])

        # space instead of equal sign
        expected_msg = "'foo.bar 1' is an invalid configuration option. Use '<rule>.<option>=<value>'"
        with self.assertRaisesRegexp(LintConfigError, expected_msg):
            config.apply_config_options(['foo.bar 1'])

        # no period between rule and option names
        expected_msg = "'foobar=1' is an invalid configuration option. Use '<rule>.<option>=<value>'"
        with self.assertRaisesRegexp(LintConfigError, expected_msg):
            config.apply_config_options(['foobar=1'])
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:28,代码来源:test_config.py

示例2: get_config

# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import apply_config_options [as 别名]
def get_config(ctx, target, config_path, c, ignore, verbose, silent):
    """ Creates a LintConfig object based on a set of commandline parameters. """
    try:
        # Config precedence:
        # First, load default config or config from configfile
        lint_config = load_config_from_path(ctx, config_path)
        # default to default configuration when no config file was loaded
        if lint_config:
            click.echo("Using config from {0}".format(lint_config.config_path))
        else:
            lint_config = LintConfig()

        # Then process any commandline configuration flags
        lint_config.apply_config_options(c)

        # Finally, overwrite with any convenience commandline flags
        lint_config.apply_on_csv_string(ignore, lint_config.disable_rule)
        if silent:
            lint_config.verbosity = 0
        elif verbose > 0:
            lint_config.verbosity = verbose

        # Set target
        lint_config.target = target
        return lint_config
    except LintConfigError as e:
        click.echo("Config Error: {0}".format(str(e)))
    ctx.exit(CONFIG_ERROR_CODE)  # return CONFIG_ERROR_CODE on config error
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:30,代码来源:cli.py

示例3: test_apply_config_options

# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import apply_config_options [as 别名]
    def test_apply_config_options(self):
        config = LintConfig()
        # assert some defaults
        self.assertEqual(config.get_rule_option('title-max-length', 'line-length'), 72)
        self.assertEqual(config.get_rule_option('body-max-line-length', 'line-length'), 80)
        self.assertEqual(config.verbosity, 3)

        # change and assert changes
        config.apply_config_options(['general.verbosity=1', 'title-max-length.line-length=60',
                                     'body-max-line-length.line-length=120'])
        self.assertEqual(config.get_rule_option('title-max-length', 'line-length'), 60)
        self.assertEqual(config.get_rule_option('body-max-line-length', 'line-length'), 120)
        self.assertEqual(config.verbosity, 1)
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:15,代码来源:test_config.py


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