Skip to content

Instantly share code, notes, and snippets.

@laurayco
Last active August 29, 2015 14:04
Show Gist options
  • Save laurayco/840a5a76d34407dbc15e to your computer and use it in GitHub Desktop.
Save laurayco/840a5a76d34407dbc15e to your computer and use it in GitHub Desktop.
import os
class TransactComplete:
def __init__(self,thing):
self.original_filename = thing.filename
self.thing = thing
thing.filename = "{}.pending".format(thing.filename)
def enter(self):return None
def exit(self,*a):
os.rename(self.original_filename,self.original_filename+".bak")
os.rename(self.original_filename+".pending",self.original_filename)
self.thing.filename = self.original_filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment