# HG changeset patch # User Jeff Hammel # Date 1355528139 28800 # Node ID 0a3c7d8eec72d6367e8e268275a033a25d1b5070 # Parent d1b8fc0cb6cbe77c53611060fcc6e4f0d650746f utilize patch to determine if a patch or not diff -r d1b8fc0cb6cb -r 0a3c7d8eec72 bzconsole/api.py --- 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""" diff -r d1b8fc0cb6cb -r 0a3c7d8eec72 setup.py --- 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'