# HG changeset patch # User Jeff Hammel # Date 1288722735 25200 # Node ID 81c0de264b8696e38864b1918916ec75af9f5b17 # Parent 43fb6fd8903df1e4b2e5b70632fb9db796ceabec add a tmpbuffer utility, from http://k0s.org/hg/bitsyblog/file/4df927b0d847/bitsyblog/blogme.py diff -r 43fb6fd8903d -r 81c0de264b86 bzconsole/utils.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bzconsole/utils.py Tue Nov 02 11:32:15 2010 -0700 @@ -0,0 +1,11 @@ +def tmpbuffer(editor=None): + """open an editor and retreive the resulting editted buffer""" + if not editor: + editor = os.environ['EDITOR'] + tmpfile = tempfile.mktemp(suffix='.txt') + cmdline = editor.split() + cmdline.append(tmpfile) + edit = subprocess.call(cmdline) + buffer = file(tmpfile).read().strip() + os.remove(tmpfile) + return buffer \ No newline at end of file