add global SENTINEL object
This commit is contained in:
@@ -139,7 +139,6 @@ def unset(path, key, *, conf=_config):
|
||||
|
||||
class apply():
|
||||
"""Context Manager: apply a collection of key-value pairs"""
|
||||
_sentinel = object()
|
||||
|
||||
def __init__(self, kvlist):
|
||||
self.original = []
|
||||
@@ -147,12 +146,12 @@ class apply():
|
||||
|
||||
def __enter__(self):
|
||||
for path, key, value in self.kvlist:
|
||||
self.original.append((path, key, get(path, key, self._sentinel)))
|
||||
self.original.append((path, key, get(path, key, util.SENTINEL)))
|
||||
set(path, key, value)
|
||||
|
||||
def __exit__(self, etype, value, traceback):
|
||||
for path, key, value in self.original:
|
||||
if value is self._sentinel:
|
||||
if value is util.SENTINEL:
|
||||
unset(path, key)
|
||||
else:
|
||||
set(path, key, value)
|
||||
|
||||
Reference in New Issue
Block a user