17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | |
def revert(namespace, name): |
""" revert to the orginal value the last patch modified. |
Raise ValueError if no such original value exists. |
""" |
nref = (namespace, name) |
if nref not in patched or not patched[nref]: |
raise ValueError, "No original value stored for %s.%s" % nref |
current = getattr(namespace, name) |
orig = patched[nref].pop() |
setattr(namespace, name, orig) |
return current | |