Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Jul 7, 2019
1 parent 58db541 commit 084dfe0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion WDL/Env2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Base(Generic[T]):
"""
``WDL.Env.Base`` is the polymorphic data structure for an environment mapping names onto some
``WDL.Env.Base`` is the generic data structure for an environment binding names onto some
associated values. WDL names are unique, and may be prefixed by dot-separated namespaces.
Bindings in the environment can be added and retrieved using dict-like syntax, except
attempting to overwrite an existing binding causes a ``Collision`` error. It's possible for an
Expand Down Expand Up @@ -48,6 +48,15 @@ def __setitem__(self, key: str, value: T) -> None:
pass
self._items[key] = value

def bind(self, key: str, value: T) -> "Base[T]":
"""
Copy the environment with an additional binding (leaving ``self`` unchanged)
"""
ans = Base(self._items)
ans._namespaces = set(self._namespaces)
ans[key] = value
return ans

def add_namespace(self, namespace: str, exist_ok: bool = False) -> None:
"""
Add a namespace to the environment. When a binding with a namespaced key is added to the
Expand Down

0 comments on commit 084dfe0

Please sign in to comment.