[python-bugzilla] [PATCH 1/2] Add field option to modify command in cli.

abn at redhat.com abn at redhat.com
Tue Jul 8 01:01:10 UTC 2014


From: Arun Babu Neelicattu <abn at redhat.com>

- Allows for modifying fields by specifying the fieldname and value.
- Useful for modifying non-standard fields.
---
 bin/bugzilla | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/bin/bugzilla b/bin/bugzilla
index 45dd8d2..b969500 100755
--- a/bin/bugzilla
+++ b/bin/bugzilla
@@ -298,6 +298,13 @@ def setup_action_parser(action):
         p.set_usage("%prog modify [options] BUGID [BUGID...]")
         p.set_description("Modify one or more bugs.")
 
+        p.add_option('--field',
+                     help="Modify a specified field. FIELD is expected to be \
+                     the raw name used by the bugzilla instance. No safety \
+                     checks are perfomed when using this option.",
+                     action="append", type="str", dest="fields",
+                     metavar="FIELD=VALUE")
+
         bgrp = optparse.OptionGroup(p, "Bug details")
         bgrp.add_option('--product',
                 help="Reassign bug to different product")
@@ -987,6 +994,15 @@ def _do_modify(bz, parser, opt, args):
         if not v[0] and not v[1]:
             del(wbmap[k])
 
+    # Add any custom fields if specified
+    if opt.fields is not None:
+        for f in opt.fields:
+            try:
+                f, v = f.split('=', 1)
+                update[f] = v
+            except:
+                parser.error("Invalid field argument provided: %s" % (f))
+
     log.debug("update bug dict=%s", update)
     log.debug("update flags dict=%s", flags)
     log.debug("update whiteboard dict=%s", wbmap)
-- 
1.9.3



More information about the python-bugzilla mailing list