summaryrefslogtreecommitdiff
path: root/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to '__init__.py')
-rw-r--r--__init__.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/__init__.py b/__init__.py
index 558868e..d9c5e64 100644
--- a/__init__.py
+++ b/__init__.py
@@ -60,6 +60,22 @@ class nullobject(object):
def __nonzero__(self):
return False
+class tempattr(object):
+ def __init__(self, obj, attr, value):
+ self.obj = obj
+ self.attr = attr
+ self.value = value
+
+ def __enter__(self):
+ self.oldvalue = getattr(self.obj, self.attr)
+ setattr(self.obj, self.attr, self.value)
+ return self.obj
+
+ def __exit__(self, exctype, value, traceback):
+ setattr(self.obj, self.attr, self.oldvalue)
+
+
+
# flatten -----
# XXX move in a specific module and use yield instead
# do not mix flatten and translate