Mercurial > libervia-backend
annotate sat/plugins/plugin_tickets_import_bugzilla.py @ 3028:ab2696e34d29
Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time
This patch port backend, bridge and frontends to Python 3.
Roughly this has been done this way:
- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:08:41 +0200 |
parents | 003b8b4b56a7 |
children | 9d0df638c8b4 |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
2373
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 |
2771 | 5 # Copyright (C) 2009-2019 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 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
23 |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 log = getLogger(__name__) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from sat.core import exceptions |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
26 |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 # from twisted.internet import threads |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from twisted.internet import defer |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 import os.path |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from lxml import etree |
2612
3e4e78de9cca
tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
31 from sat.tools.common import date_utils |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 PLUGIN_INFO = { |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 C.PI_NAME: "Bugzilla import", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 C.PI_IMPORT_NAME: "IMPORT_BUGZILLA", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 C.PI_TYPE: C.PLUG_TYPE_BLOG, |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 C.PI_DEPENDENCIES: ["TICKETS_IMPORT"], |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 C.PI_MAIN: "BugzillaImport", |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 C.PI_HANDLER: "no", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
41 C.PI_DESCRIPTION: _("""Tickets importer for Bugzilla"""), |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 } |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 |
3028 | 44 SHORT_DESC = D_("import tickets from Bugzilla xml export file") |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
46 LONG_DESC = D_( |
3028 | 47 """This importer handle Bugzilla xml export file. |
2373
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 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
|
50 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
|
51 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 location: you must use the absolute path to your .xml file |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
53 """ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
54 ) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
56 STATUS_MAP = { |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
57 "NEW": "queued", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
58 "ASSIGNED": "started", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
59 "RESOLVED": "review", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
60 "CLOSED": "closed", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
61 "REOPENED": "started", # we loose data here because there is no need on basic workflow to have a reopened status |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
62 } |
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
63 |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 class BugzillaParser(object): |
2382
a49a19f06e38
plugin import ticket, import ticket bugzilla: some normalization in values:
Goffi <goffi@goffi.org>
parents:
2373
diff
changeset
|
66 # TODO: add a way to reassign values |
2373
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 def parse(self, file_path): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 tickets = [] |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 root = etree.parse(file_path) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
72 for bug in root.xpath("bug"): |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 ticket = {} |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
74 ticket["id"] = bug.findtext("bug_id") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
75 ticket["created"] = date_utils.date_parse(bug.findtext("creation_ts")) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
76 ticket["updated"] = date_utils.date_parse(bug.findtext("delta_ts")) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
77 ticket["title"] = bug.findtext("short_desc") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
78 reporter_elt = bug.find("reporter") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
79 ticket["author"] = reporter_elt.get("name") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
80 if ticket["author"] is None: |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
81 if "@" in reporter_elt.text: |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
82 ticket["author"] = reporter_elt.text[ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
83 : reporter_elt.text.find("@") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
84 ].title() |
2390
f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
Goffi <goffi@goffi.org>
parents:
2382
diff
changeset
|
85 else: |
3028 | 86 ticket["author"] = "no name" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
87 ticket["author_email"] = reporter_elt.text |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
88 assigned_to_elt = bug.find("assigned_to") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
89 ticket["assigned_to_name"] = assigned_to_elt.get("name") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
90 ticket["assigned_to_email"] = assigned_to_elt.text |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
91 ticket["cc_emails"] = [e.text for e in bug.findall("cc")] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
92 ticket["priority"] = bug.findtext("priority").lower().strip() |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
93 ticket["severity"] = bug.findtext("bug_severity").lower().strip() |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
94 ticket["product"] = bug.findtext("product") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
95 ticket["component"] = bug.findtext("component") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
96 ticket["version"] = bug.findtext("version") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
97 ticket["platform"] = bug.findtext("rep_platform") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
98 ticket["os"] = bug.findtext("op_sys") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
99 ticket["status"] = STATUS_MAP.get(bug.findtext("bug_status"), "queued") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
100 ticket["milestone"] = bug.findtext("target_milestone") |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 body = None |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 comments = [] |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
104 for longdesc in bug.findall("long_desc"): |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 if body is None: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
106 body = longdesc.findtext("thetext") |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 else: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
108 who = longdesc.find("who") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
109 comment = { |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
110 "id": longdesc.findtext("commentid"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
111 "author_email": who.text, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
112 "published": date_utils.date_parse(longdesc.findtext("bug_when")), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
113 "author": who.get("name", who.text), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
114 "content": longdesc.findtext("thetext"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
115 } |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 comments.append(comment) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
118 ticket["body"] = body |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
119 ticket["comments"] = comments |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 tickets.append(ticket) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
122 tickets.sort(key=lambda t: int(t["id"])) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 return (tickets, len(tickets)) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 |
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 class BugzillaImport(object): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 def __init__(self, host): |
3028 | 128 log.info(_("Bugilla Import plugin initialization")) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 self.host = host |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
130 host.plugins["TICKETS_IMPORT"].register( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
131 "bugzilla", self.Import, SHORT_DESC, LONG_DESC |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
132 ) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 def Import(self, client, location, options=None): |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 if not os.path.isabs(location): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
136 raise exceptions.DataError( |
3028 | 137 "An absolute path to XML data need to be given as location" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
138 ) |
2373
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 bugzilla_parser = BugzillaParser() |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 # d = threads.deferToThread(bugzilla_parser.parse, location) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 d = defer.maybeDeferred(bugzilla_parser.parse, location) |
d2476dc2d55d
plugin tickets import Bugzilla: Bugzilla tickets importer:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 return d |