changeset 38:0a3c7d8eec72

utilize patch to determine if a patch or not
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 14 Dec 2012 15:35:39 -0800
parents d1b8fc0cb6cb
children 15c264451c3d
files bzconsole/api.py setup.py
diffstat 2 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bzconsole/api.py	Fri Dec 14 15:18:01 2012 -0800
+++ b/bzconsole/api.py	Fri Dec 14 15:35:39 2012 -0800
@@ -5,6 +5,7 @@
 import httplib
 import json
 import os
+import patch
 import subprocess
 import sys
 import urllib
@@ -179,17 +180,28 @@
             basename  = os.path.basename(attachment)
             contents = file(attachment).read()
 
+        is_patch = bool(patch.fromstring(contents))
+
+        # patch flags
+        flags = []
+        if reviewer:
+            # from
+            # https://github.com/toolness/pybugzilla/blob/master/bzpatch.py#L177
+            flags.append({'status': '?',
+                          'requestee': reviewer}
+            pass # TODO
+
         # create attachment data structure
         # https://wiki.mozilla.org/Bugzilla:REST_API:Objects#Attachment
         attachment= {'bug': int(bug),
                      'description': description,
-                     'file_name': basename
+                     'file_name': basename,
+                     'flags': flags,
+                     'is_patch': is_patch,
+                     'is_private': False
                      }
-        if reviewer:
-            flags = []
-            pass # TODO
 
-        self.request('/bug/%s/attachment' % bug, attachment)
+        self._request('/bug/%s/attachment' % bug, attachment)
 
     def configuration(self):
         """bugzilla configuration"""
--- a/setup.py	Fri Dec 14 15:18:01 2012 -0800
+++ b/setup.py	Fri Dec 14 15:35:39 2012 -0800
@@ -23,6 +23,7 @@
       packages=['bzconsole'],
       include_package_data=True,
       zip_safe=False,
+      # http://packages.python.org/distribute/setuptools.html#declaring-dependencies
       install_requires=['patch'],
       dependency_links=[
         'http://python-patch.googlecode.com/svn/trunk/patch.py#egg=patch-0.0'