changeset 56:baecb5a6f05b

some more thangs
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 22 Sep 2013 17:37:44 -0700
parents a5b7ea791f64
children 027a85c2a6d7
files bzconsole/api.py bzconsole/main.py bzconsole/utils.py
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/bzconsole/api.py	Thu Sep 19 13:04:03 2013 -0700
+++ b/bzconsole/api.py	Sun Sep 22 17:37:44 2013 -0700
@@ -132,7 +132,7 @@
 
     def new(self, component, title, product=None,
             version=None, description=None, whiteboard=(), cc=(),
-            blocks=(), depends_on=()):
+            blocks=(), depends_on=(), see_also=()):
         """file a new bug. username and password must be set"""
 
         # sanity check
@@ -185,7 +185,15 @@
             depends_on = [int(i) for i in depends_on]
             request['depends_on'] = depends_on
 
+        if see_also:
+            if isinstance(see_also, string):
+                see_also = [see_also]
+            request['see_also'] = list(see_also)
+
         # get the bug description
+        if os.path.exists(description):
+            description = file(description).read()
+            description = tmpbuffer(contents=description)
         if not description:
             description = tmpbuffer()
         assert description, "Must provide a non-empty description"
--- a/bzconsole/main.py	Thu Sep 19 13:04:03 2013 -0700
+++ b/bzconsole/main.py	Sun Sep 22 17:37:44 2013 -0700
@@ -8,6 +8,10 @@
 class BZcli(BZapi):
     """command line interface front-end for the API class"""
 
+    def file(self, component, title, path, **kwargs):
+        """read from a file [NOTIMPLEMENTED]"""
+        raise NotImplementedError
+
     def unique(self, component=None):
         """display unique and duplicated components"""
         unique, dupe = self._unique_components()
--- a/bzconsole/utils.py	Thu Sep 19 13:04:03 2013 -0700
+++ b/bzconsole/utils.py	Sun Sep 22 17:37:44 2013 -0700
@@ -2,11 +2,15 @@
 import subprocess
 import tempfile
 
-def tmpbuffer(editor=None):
+def tmpbuffer(editor=None, contents=None):
     """open an editor and retreive the resulting editted buffer"""
     if not editor:
         editor = os.environ['EDITOR']
-    tmpfile = tempfile.mktemp(suffix='.txt')
+    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)