git @ Cat's Eye Technologies SixtyPical / eb4ed6a
Extract locations from context appropriately. All tests pass. Chris Pressey 4 years ago
1 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
292292 self.set_written(dest.ref)
293293
294294 def extract(self, location):
295 """Used in `save`."""
295 """Sets the given location as writeable in the context, and returns a 'baton' representing
296 the previous state of context for that location. This 'baton' can be used to later restore
297 this state of context."""
298 # Used in `save`.
296299 baton = (
297300 location,
298301 location in self._touched,
299302 self._range.get(location, None),
300303 location in self._writeable,
301304 )
302
303 if location in self._touched:
304 self._touched.remove(location)
305 self.set_unmeaningful(location)
306305 self.set_writeable(location)
307
308306 return baton
309307
310308 def re_introduce(self, baton):
311 """Used in `save`."""
309 """Given a 'baton' produced by `extract()`, restores the context for that saved location
310 to what it was before `extract()` was called."""
311 # Used in `save`.
312312 location, was_touched, was_range, was_writeable = baton
313313
314314 if was_touched: