Mercurial > hg > bzconsole
view bzconsole/utils.py @ 57:027a85c2a6d7
bzconsole/main.py bzconsole/utils.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 26 Sep 2013 02:39:31 -0700 |
parents | baecb5a6f05b |
children |
line wrap: on
line source
import os import subprocess import tempfile def tmpbuffer(editor=None, contents=None): """open an editor and retreive the resulting editted buffer""" if not editor: editor = os.environ['EDITOR'] assert editor fd, tmpfile = tempfile.mkstemp(suffix='.txt') if contents: os.write(fd, contents) os.close(fd) cmdline = editor.split() cmdline.append(tmpfile) edit = subprocess.call(cmdline) buffer = file(tmpfile).read().strip() os.remove(tmpfile) return buffer def match(string): """return bug # in the string or None if not found""" string = string.lower() index = string.find('bug') if index == -1: return index += len('bug') if string[index+1] in ('-', ' ', '+', '_', '=',): index += 1 start = index raise NotImplementedError