Skip to content

Instantly share code, notes, and snippets.

@omasanori
Created December 22, 2009 00:18
Show Gist options
  • Save omasanori/261386 to your computer and use it in GitHub Desktop.
Save omasanori/261386 to your computer and use it in GitHub Desktop.
--- pit.py.orig 2009-12-22 03:49:04.953125000 +0900
+++ pit.py.added 2009-12-22 03:47:37.671875000 +0900
@@ -18,13 +18,15 @@
else:
if not os.environ.has_key('EDITOR'):
return {}
- t = tempfile.NamedTemporaryFile()
+ t, path = tempfile.mkstemp()
c = yaml.dump(opts['config'] if opts.has_key('config') else Pit.get(name) ,default_flow_style=False)
t.write(c)
- t.flush()
- path = os.path.abspath(t.name)
+ t.close()
Popen([os.environ['EDITOR'],path]).communicate()
- result = open(path).read()
+ t = open(path)
+ result = t.read()
+ t.close()
+ os.remove(t)
if result == c:
print 'No Changes'
return profile[name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment