本文整理汇总了Python中environs.Env方法的典型用法代码示例。如果您正苦于以下问题:Python environs.Env方法的具体用法?Python environs.Env怎么用?Python environs.Env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类environs
的用法示例。
在下文中一共展示了environs.Env方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_configs
# 需要导入模块: import environs [as 别名]
# 或者: from environs import Env [as 别名]
def parse_configs():
env = Env()
env.read_env()
config.battle_bot_module = env("BATTLE_BOT", 'safest')
config.save_replay = env.bool("SAVE_REPLAY", config.save_replay)
config.use_relative_weights = env.bool("USE_RELATIVE_WEIGHTS", config.use_relative_weights)
config.gambit_exe_path = env("GAMBIT_PATH", config.gambit_exe_path)
config.search_depth = int(env("MAX_SEARCH_DEPTH", config.search_depth))
config.greeting_message = env("GREETING_MESSAGE", config.greeting_message)
config.battle_ending_message = env("BATTLE_OVER_MESSAGE", config.battle_ending_message)
config.websocket_uri = env("WEBSOCKET_URI", "sim.smogon.com:8000")
config.username = env("PS_USERNAME")
config.password = env("PS_PASSWORD", "")
config.bot_mode = env("BOT_MODE")
config.team_name = env("TEAM_NAME", None)
config.pokemon_mode = env("POKEMON_MODE", constants.DEFAULT_MODE)
config.run_count = int(env("RUN_COUNT", 1))
if config.bot_mode == constants.CHALLENGE_USER:
config.user_to_challenge = env("USER_TO_CHALLENGE")
init_logging(env("LOG_LEVEL", "DEBUG"))
示例2: env
# 需要导入模块: import environs [as 别名]
# 或者: from environs import Env [as 别名]
def env():
return environs.Env()
示例3: test_repr
# 需要导入模块: import environs [as 别名]
# 或者: from environs import Env [as 别名]
def test_repr(set_env, env):
set_env({"FOO": "foo", "BAR": "42"})
env.str("FOO")
assert repr(env) == "<Env {}>".format({"FOO": "foo"})
示例4: test_str
# 需要导入模块: import environs [as 别名]
# 或者: from environs import Env [as 别名]
def test_str(set_env, env):
set_env({"FOO": "foo", "BAR": "42"})
env.str("FOO")
assert repr(env) == "<Env {}>".format({"FOO": "foo"})
示例5: test_env_isolation
# 需要导入模块: import environs [as 别名]
# 或者: from environs import Env [as 别名]
def test_env_isolation(set_env):
set_env({"FOO": "foo"})
env1 = environs.Env()
@env1.parser_for("foo")
def foo(value):
return value
env2 = environs.Env()
# env1 has a parser for foo, but env2 does not
assert env1.foo("FOO") == "foo"
with pytest.raises(AttributeError):
env2.foo("FOO")
示例6: test_custom_parser_not_called_after_seal
# 需要导入模块: import environs [as 别名]
# 或者: from environs import Env [as 别名]
def test_custom_parser_not_called_after_seal(self, env, set_env):
set_env({"URL": "test.test/"})
@env.parser_for("https_url")
def https_url(value):
return "https://" + value
env.seal()
with pytest.raises(environs.EnvSealedError, match="Env has already been sealed"):
env.https_url("URL")