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


Python Config.from_file方法代码示例

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


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

示例1: test_from_file

# 需要导入模块: from twtxt.config import Config [as 别名]
# 或者: from twtxt.config.Config import from_file [as 别名]
def test_from_file(config_dir):
    with pytest.raises(ValueError) as e:
        Config.from_file("invalid")
    assert "Config file not found." in str(e.value)

    with open(str(config_dir.join("empty")), "a") as fh:
        fh.write("XXX")
    with pytest.raises(ValueError) as e:
        Config.from_file(str(config_dir.join("empty")))
    assert "Config file is invalid." in str(e.value)

    conf = Config.from_file(str(config_dir.join(Config.config_name)))
    check_cfg(conf)
开发者ID:timofurrer,项目名称:twtxt,代码行数:15,代码来源:test_config.py

示例2: test_check_config_file_sanity

# 需要导入模块: from twtxt.config import Config [as 别名]
# 或者: from twtxt.config.Config import from_file [as 别名]
def test_check_config_file_sanity(capsys, config_dir):
    with pytest.raises(ValueError) as e:
        Config.from_file(str(config_dir.join("config_sanity")))
    assert "Error in config file." in str(e.value)

    out, err = capsys.readouterr()
    for line in ["✗ Config error on limit_timeline - invalid literal for int() with base 10: '2t0'",
                 "✗ Config error on check_following - Not a boolean: TTrue",
                 "✗ Config error on porcelain - Not a boolean: Faltse",
                 "✗ Config error on disclose_identity - Not a boolean: Ftalse",
                 "✗ Config error on timeout - could not convert string to float: '5t.0'",
                 "✗ Config error on use_pager - Not a boolean: Falste",
                 "✗ Config error on use_cache - Not a boolean: Trute"]:
        assert line in out
开发者ID:Creative-Reflex,项目名称:twtxt,代码行数:16,代码来源:test_config.py

示例3: cli

# 需要导入模块: from twtxt.config import Config [as 别名]
# 或者: from twtxt.config.Config import from_file [as 别名]
def cli(ctx, config, verbose):
    """Decentralised, minimalist microblogging service for hackers."""
    init_logging(debug=verbose)

    try:
        if config:
            conf = Config.from_file(config)
        else:
            conf = Config.discover()
    except ValueError:
        click.echo("Error loading config file.")
        if not config:
            if click.confirm("Do you want to run the twtxt quickstart wizard?", abort=True):
                pass

    ctx.default_map = conf.build_default_map()
    ctx.obj = {'conf': conf}
开发者ID:gitter-badger,项目名称:twtxt,代码行数:19,代码来源:cli.py

示例4: cli

# 需要导入模块: from twtxt.config import Config [as 别名]
# 或者: from twtxt.config.Config import from_file [as 别名]
def cli(ctx, config, verbose):
    """Decentralised, minimalist microblogging service for hackers."""
    init_logging(debug=verbose)

    if ctx.invoked_subcommand == "quickstart":
        return

    try:
        if config:
            conf = Config.from_file(config)
        else:
            conf = Config.discover()
    except ValueError:
        click.echo("✗ Config file not found or not readable. You may want to run twtxt quickstart.")
        sys.exit()

    ctx.default_map = conf.build_default_map()
    ctx.obj = {'conf': conf}
开发者ID:timofurrer,项目名称:twtxt,代码行数:20,代码来源:cli.py

示例5: cli

# 需要导入模块: from twtxt.config import Config [as 别名]
# 或者: from twtxt.config.Config import from_file [as 别名]
def cli(ctx, config, verbose):
    """Decentralised, minimalist microblogging service for hackers."""
    init_logging(debug=verbose)

    if ctx.invoked_subcommand == "quickstart":
        return  # Skip initializing config file

    try:
        if config:
            conf = Config.from_file(config)
        else:
            conf = Config.discover()
    except ValueError as e:
        if "Error in config file." in str(e):
            click.echo("✗ Please correct the errors mentioned above an run twtxt again.")
        else:
            click.echo("✗ Config file not found or not readable. You may want to run twtxt quickstart.")
        sys.exit()

    ctx.default_map = conf.build_default_map()
    ctx.obj = {'conf': conf}
开发者ID:DracoBlue,项目名称:twtxt,代码行数:23,代码来源:cli.py


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