diff src/plugins/plugin_tickets_import_bugzilla.py @ 2382:a49a19f06e38

plugin import ticket, import ticket bugzilla: some normalization in values: normalization (i.e. recommandations for importer to have similar values) has been done for some values: - "status" is now one of "queued", "started", "review", "closed" - "priority" and "severity" must be stripped and lower case
author Goffi <goffi@goffi.org>
date Mon, 16 Oct 2017 07:39:54 +0200
parents d2476dc2d55d
children f57a8eaec8ed
line wrap: on
line diff
--- a/src/plugins/plugin_tickets_import_bugzilla.py	Mon Oct 16 07:36:41 2017 +0200
+++ b/src/plugins/plugin_tickets_import_bugzilla.py	Mon Oct 16 07:39:54 2017 +0200
@@ -48,9 +48,17 @@
 location: you must use the absolute path to your .xml file
 """)
 
+STATUS_MAP = {
+    'NEW': 'queued',
+    'ASSIGNED': 'started',
+    'RESOLVED': 'review',
+    'CLOSED': 'closed',
+    'REOPENED': 'started'  # we loose data here because there is no need on basic workflow to have a reopened status
+}
+
 
 class BugzillaParser(object):
-
+    # TODO: add a way to reassign values
 
     def parse(self, file_path):
         tickets = []
@@ -69,14 +77,14 @@
             ticket['assigned_to_name'] = assigned_to_elt.get('name')
             ticket['assigned_to_email'] = assigned_to_elt.text
             ticket['cc_emails'] = [e.text for e in bug.findall('cc')]
-            ticket['priority'] = bug.findtext('priority')
-            ticket['severity'] = bug.findtext('bug_severity')
+            ticket['priority'] = bug.findtext('priority').lower().strip()
+            ticket['severity'] = bug.findtext('bug_severity').lower().strip()
             ticket['product'] = bug.findtext('product')
             ticket['component'] = bug.findtext('component')
             ticket['version'] = bug.findtext('version')
             ticket['platform'] = bug.findtext('rep_platform')
             ticket['os'] = bug.findtext('op_sys')
-            ticket['status'] = bug.findtext('bug_status')
+            ticket['status'] = STATUS_MAP.get(bug.findtext('bug_status'), 'queued')
             ticket['milestone'] = bug.findtext('target_milestone')