mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-29 03:51:35 +00:00
Extract locations from context appropriately. All tests pass.
This commit is contained in:
parent
d037401b18
commit
eb4ed6a6bc
@ -293,23 +293,23 @@ class Context(object):
|
|||||||
self.set_written(dest.ref)
|
self.set_written(dest.ref)
|
||||||
|
|
||||||
def extract(self, location):
|
def extract(self, location):
|
||||||
"""Used in `save`."""
|
"""Sets the given location as writeable in the context, and returns a 'baton' representing
|
||||||
|
the previous state of context for that location. This 'baton' can be used to later restore
|
||||||
|
this state of context."""
|
||||||
|
# Used in `save`.
|
||||||
baton = (
|
baton = (
|
||||||
location,
|
location,
|
||||||
location in self._touched,
|
location in self._touched,
|
||||||
self._range.get(location, None),
|
self._range.get(location, None),
|
||||||
location in self._writeable,
|
location in self._writeable,
|
||||||
)
|
)
|
||||||
|
|
||||||
if location in self._touched:
|
|
||||||
self._touched.remove(location)
|
|
||||||
self.set_unmeaningful(location)
|
|
||||||
self.set_writeable(location)
|
self.set_writeable(location)
|
||||||
|
|
||||||
return baton
|
return baton
|
||||||
|
|
||||||
def re_introduce(self, baton):
|
def re_introduce(self, baton):
|
||||||
"""Used in `save`."""
|
"""Given a 'baton' produced by `extract()`, restores the context for that saved location
|
||||||
|
to what it was before `extract()` was called."""
|
||||||
|
# Used in `save`.
|
||||||
location, was_touched, was_range, was_writeable = baton
|
location, was_touched, was_range, was_writeable = baton
|
||||||
|
|
||||||
if was_touched:
|
if was_touched:
|
||||||
|
Loading…
Reference in New Issue
Block a user