comparison 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
comparison
equal deleted inserted replaced
2381:72c30e73a9a5 2382:a49a19f06e38
46 Tickets will be uploaded with the same ID as for Bugzilla, any existing ticket with this ID will be replaced. 46 Tickets will be uploaded with the same ID as for Bugzilla, any existing ticket with this ID will be replaced.
47 47
48 location: you must use the absolute path to your .xml file 48 location: you must use the absolute path to your .xml file
49 """) 49 """)
50 50
51 STATUS_MAP = {
52 'NEW': 'queued',
53 'ASSIGNED': 'started',
54 'RESOLVED': 'review',
55 'CLOSED': 'closed',
56 'REOPENED': 'started' # we loose data here because there is no need on basic workflow to have a reopened status
57 }
58
51 59
52 class BugzillaParser(object): 60 class BugzillaParser(object):
53 61 # TODO: add a way to reassign values
54 62
55 def parse(self, file_path): 63 def parse(self, file_path):
56 tickets = [] 64 tickets = []
57 root = etree.parse(file_path) 65 root = etree.parse(file_path)
58 66
67 ticket['reporter_email'] = reporter_elt.text 75 ticket['reporter_email'] = reporter_elt.text
68 assigned_to_elt = bug.find('assigned_to') 76 assigned_to_elt = bug.find('assigned_to')
69 ticket['assigned_to_name'] = assigned_to_elt.get('name') 77 ticket['assigned_to_name'] = assigned_to_elt.get('name')
70 ticket['assigned_to_email'] = assigned_to_elt.text 78 ticket['assigned_to_email'] = assigned_to_elt.text
71 ticket['cc_emails'] = [e.text for e in bug.findall('cc')] 79 ticket['cc_emails'] = [e.text for e in bug.findall('cc')]
72 ticket['priority'] = bug.findtext('priority') 80 ticket['priority'] = bug.findtext('priority').lower().strip()
73 ticket['severity'] = bug.findtext('bug_severity') 81 ticket['severity'] = bug.findtext('bug_severity').lower().strip()
74 ticket['product'] = bug.findtext('product') 82 ticket['product'] = bug.findtext('product')
75 ticket['component'] = bug.findtext('component') 83 ticket['component'] = bug.findtext('component')
76 ticket['version'] = bug.findtext('version') 84 ticket['version'] = bug.findtext('version')
77 ticket['platform'] = bug.findtext('rep_platform') 85 ticket['platform'] = bug.findtext('rep_platform')
78 ticket['os'] = bug.findtext('op_sys') 86 ticket['os'] = bug.findtext('op_sys')
79 ticket['status'] = bug.findtext('bug_status') 87 ticket['status'] = STATUS_MAP.get(bug.findtext('bug_status'), 'queued')
80 ticket['milestone'] = bug.findtext('target_milestone') 88 ticket['milestone'] = bug.findtext('target_milestone')
81 89
82 90
83 body = None 91 body = None
84 comments = [] 92 comments = []