This commit is contained in:
Anthony Scopatz 2019-02-14 10:00:20 -05:00
parent 41c240a7ee
commit 43d0527657
4 changed files with 17 additions and 11 deletions

View file

@ -29,6 +29,7 @@
* New ``xonsh.tools.detype()`` function that simply calls an objects own
``detype()`` method in order to detype it.
* New ``xonsh.tools.always_none()`` function that simply returns None.
* New ``Env.set_ensurer()`` method for setting an ensurer on an environment.
**Changed:**

View file

@ -68,7 +68,7 @@ def test_env_detype_mutable_access_clear(path1, path2):
def test_env_detype_no_dict():
env = Env(YO={"hey": 42})
env.get_ensurer('YO', default=Ensurer(always_true, None, None))
env.set_ensurer('YO', Ensurer(always_true, None, None))
det = env.detype()
assert "YO" not in det

View file

@ -22,6 +22,8 @@ else:
_sys.modules["xonsh.lazyasd"] = __amalgam__
lazyjson = __amalgam__
_sys.modules["xonsh.lazyjson"] = __amalgam__
color_tools = __amalgam__
_sys.modules["xonsh.color_tools"] = __amalgam__
platform = __amalgam__
_sys.modules["xonsh.platform"] = __amalgam__
pretty = __amalgam__
@ -36,10 +38,10 @@ else:
_sys.modules["xonsh.tokenize"] = __amalgam__
tools = __amalgam__
_sys.modules["xonsh.tools"] = __amalgam__
ansi_colors = __amalgam__
_sys.modules["xonsh.ansi_colors"] = __amalgam__
ast = __amalgam__
_sys.modules["xonsh.ast"] = __amalgam__
color_tools = __amalgam__
_sys.modules["xonsh.color_tools"] = __amalgam__
commands_cache = __amalgam__
_sys.modules["xonsh.commands_cache"] = __amalgam__
diff_history = __amalgam__
@ -56,18 +58,18 @@ else:
_sys.modules["xonsh.lexer"] = __amalgam__
openpy = __amalgam__
_sys.modules["xonsh.openpy"] = __amalgam__
style_tools = __amalgam__
_sys.modules["xonsh.style_tools"] = __amalgam__
xontribs = __amalgam__
_sys.modules["xonsh.xontribs"] = __amalgam__
ansi_colors = __amalgam__
_sys.modules["xonsh.ansi_colors"] = __amalgam__
dirstack = __amalgam__
_sys.modules["xonsh.dirstack"] = __amalgam__
inspectors = __amalgam__
_sys.modules["xonsh.inspectors"] = __amalgam__
proc = __amalgam__
_sys.modules["xonsh.proc"] = __amalgam__
shell = __amalgam__
_sys.modules["xonsh.shell"] = __amalgam__
style_tools = __amalgam__
_sys.modules["xonsh.style_tools"] = __amalgam__
timings = __amalgam__
_sys.modules["xonsh.timings"] = __amalgam__
xonfig = __amalgam__
@ -76,14 +78,12 @@ else:
_sys.modules["xonsh.base_shell"] = __amalgam__
environ = __amalgam__
_sys.modules["xonsh.environ"] = __amalgam__
inspectors = __amalgam__
_sys.modules["xonsh.inspectors"] = __amalgam__
tracer = __amalgam__
_sys.modules["xonsh.tracer"] = __amalgam__
readline_shell = __amalgam__
_sys.modules["xonsh.readline_shell"] = __amalgam__
replay = __amalgam__
_sys.modules["xonsh.replay"] = __amalgam__
tracer = __amalgam__
_sys.modules["xonsh.tracer"] = __amalgam__
aliases = __amalgam__
_sys.modules["xonsh.aliases"] = __amalgam__
dumb_shell = __amalgam__

View file

@ -1403,6 +1403,11 @@ class Env(cabc.MutableMapping):
self._ensurers[key] = ensurer
return ensurer
def set_ensurer(self, key, value):
"""Sets an ensurer."""
self._detyped = None
self._ensurers[key] = value
def get_docs(self, key, default=VarDocs("<no documentation>")):
"""Gets the documentation for the environment variable."""
vd = self._docs.get(key, None)