예제 #1
0
파일: environ.py 프로젝트: ergs/fixie
def setup():
    global _ENV_SETUP
    if _ENV_SETUP:
        return
    for key, (default, validate, convert, detype, docstr) in ENVVARS.items():
        if key in ENV:
            del ENV[key]
        ENV._defaults[key] = default() if callable(default) else default
        ENV._ensurers[key] = Ensurer(validate=validate, convert=convert,
                                     detype=detype)
        ENV._docs[key] = VarDocs(docstr=docstr)
    _ENV_SETUP = True
예제 #2
0
def setup():
    global _ENV_SETUP
    if _ENV_SETUP:
        return
    env = builtins.__xonsh_env__
    updates = {}
    for key, (default, validate, convert, detype, docstr) in ENVVARS.items():
        if key in env:
            updates[key] = env.pop(key)
        env._defaults[key] = default() if callable(default) else default
        env._ensurers[key] = Ensurer(validate=validate,
                                     convert=convert,
                                     detype=detype)
        env._docs[key] = VarDocs(docstr=docstr)
    env.update(updates)
    _ENV_SETUP = True
예제 #3
0
def test_env_detype_no_dict():
    env = Env(YO={"hey": 42})
    env.set_ensurer("YO", Ensurer(always_true, None, None))
    det = env.detype()
    assert "YO" not in det