Mercurial > libervia-backend
annotate src/plugins/plugin_tickets_import_bugzilla.py @ 2471:544c4d2fec45
plugins schema, merge_requests, tickets*: factorisation
Dode common in plugins using schema have been factorised in pubsub schema plugin, and filters users in tickets handling have been renamed in a more generic way and put there too.
"reporter*" fields in tickets have been renamed to "author*" as it is a more generic term which can be used elsewhere.
The use of new utils.partial function make easy the creation of simple plugins using schema.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Jan 2018 15:58:54 +0100 |
parents | 8b37a62336c3 |
children | 0046283a285d |
rev | line source |
---|---|
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # SàT plugin for import external blogs |
2414
8b37a62336c3
misc: date update (yes it's a bit late :p )
Goffi <goffi@goffi.org>
parents:
2399
diff
changeset
|
5 # Copyright (C) 2009-2017 Jérôme Poisson (goffi@goffi.org) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from sat.core.i18n import _, D_ |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from sat.core.constants import Const as C |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from sat.core.log import getLogger |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 log = getLogger(__name__) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat.core import exceptions |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 # from twisted.internet import threads |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from twisted.internet import defer |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 import os.path |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from lxml import etree |
2390
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
29 from sat.tools import utils |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 PLUGIN_INFO = { |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 C.PI_NAME: "Bugzilla import", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 C.PI_IMPORT_NAME: "IMPORT_BUGZILLA", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 C.PI_TYPE: C.PLUG_TYPE_BLOG, |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 C.PI_DEPENDENCIES: ["TICKETS_IMPORT"], |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 C.PI_MAIN: "BugzillaImport", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 C.PI_HANDLER: "no", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 C.PI_DESCRIPTION: _("""Tickets importer for Bugzilla""") |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 } |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 SHORT_DESC = D_(u"import tickets from Bugzilla xml export file") |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 LONG_DESC = D_(u"""This importer handle Bugzilla xml export file. |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 To use it, you'll need to export tickets using XML. |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 Tickets will be uploaded with the same ID as for Bugzilla, any existing ticket with this ID will be replaced. |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 location: you must use the absolute path to your .xml file |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 """) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
52 STATUS_MAP = { |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
53 'NEW': 'queued', |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
54 'ASSIGNED': 'started', |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
55 'RESOLVED': 'review', |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
56 'CLOSED': 'closed', |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
57 'REOPENED': 'started' # we loose data here because there is no need on basic workflow to have a reopened status |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
58 } |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
59 |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 class BugzillaParser(object): |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
62 # TODO: add a way to reassign values |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 def parse(self, file_path): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 tickets = [] |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 root = etree.parse(file_path) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 for bug in root.xpath('bug'): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 ticket = {} |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 ticket['id'] = bug.findtext('bug_id') |
2399
acfc481629ac
plugin tickets import bugzilla: fixed parsing of "created" and "updated" fields
Goffi <goffi@goffi.org>
parents:
2390
diff
changeset
|
71 ticket['created'] = utils.date_parse(bug.findtext('creation_ts')) |
acfc481629ac
plugin tickets import bugzilla: fixed parsing of "created" and "updated" fields
Goffi <goffi@goffi.org>
parents:
2390
diff
changeset
|
72 ticket['updated'] = utils.date_parse(bug.findtext('delta_ts')) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 ticket['title'] = bug.findtext('short_desc') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 reporter_elt = bug.find('reporter') |
2471
544c4d2fec45
plugins schema, merge_requests, tickets*: factorisation
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
75 ticket['author'] = reporter_elt.get('name') |
544c4d2fec45
plugins schema, merge_requests, tickets*: factorisation
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
76 if ticket['author'] is None: |
2390
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
77 if '@' in reporter_elt.text: |
2471
544c4d2fec45
plugins schema, merge_requests, tickets*: factorisation
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
78 ticket['author'] = reporter_elt.text[:reporter_elt.text.find('@')].title() |
2390
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
79 else: |
2471
544c4d2fec45
plugins schema, merge_requests, tickets*: factorisation
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
80 ticket['author'] = u'no name' |
544c4d2fec45
plugins schema, merge_requests, tickets*: factorisation
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
81 ticket['author_email'] = reporter_elt.text |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 assigned_to_elt = bug.find('assigned_to') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 ticket['assigned_to_name'] = assigned_to_elt.get('name') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 ticket['assigned_to_email'] = assigned_to_elt.text |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 ticket['cc_emails'] = [e.text for e in bug.findall('cc')] |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
86 ticket['priority'] = bug.findtext('priority').lower().strip() |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
87 ticket['severity'] = bug.findtext('bug_severity').lower().strip() |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 ticket['product'] = bug.findtext('product') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 ticket['component'] = bug.findtext('component') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 ticket['version'] = bug.findtext('version') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 ticket['platform'] = bug.findtext('rep_platform') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 ticket['os'] = bug.findtext('op_sys') |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
93 ticket['status'] = STATUS_MAP.get(bug.findtext('bug_status'), 'queued') |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 ticket['milestone'] = bug.findtext('target_milestone') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 body = None |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 comments = [] |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 for longdesc in bug.findall('long_desc'): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 if body is None: |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 body = longdesc.findtext('thetext') |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 else: |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 who = longdesc.find('who') |
2390
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
104 comment = {'id': longdesc.findtext('commentid'), |
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
105 'author_email': who.text, |
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
106 'published': utils.date_parse(longdesc.findtext('bug_when')), |
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
107 'author': who.get('name', who.text), |
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
108 'content': longdesc.findtext('thetext')} |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 comments.append(comment) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 ticket['body'] = body |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 ticket['comments'] = comments |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 tickets.append(ticket) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 tickets.sort(key = lambda t: int(t['id'])) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 return (tickets, len(tickets)) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 class BugzillaImport(object): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 def __init__(self, host): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 log.info(_(u"Bugilla Import plugin initialization")) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 self.host = host |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 host.plugins['TICKETS_IMPORT'].register('bugzilla', self.Import, SHORT_DESC, LONG_DESC) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 def Import(self, client, location, options=None): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 if not os.path.isabs(location): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 raise exceptions.DataError(u"An absolute path to XML data need to be given as location") |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 bugzilla_parser = BugzillaParser() |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 # d = threads.deferToThread(bugzilla_parser.parse, location) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 d = defer.maybeDeferred(bugzilla_parser.parse, location) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 return d |