Mercurial > libervia-backend
comparison sat/plugins/plugin_tickets_import_bugzilla.py @ 2612:3e4e78de9cca
tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 21 Jun 2018 01:21:44 +0200 |
parents | 26edcf3a30eb |
children | 56f94936df1e |
comparison
equal
deleted
inserted
replaced
2611:c180ca699e72 | 2612:3e4e78de9cca |
---|---|
24 from sat.core import exceptions | 24 from sat.core import exceptions |
25 # from twisted.internet import threads | 25 # from twisted.internet import threads |
26 from twisted.internet import defer | 26 from twisted.internet import defer |
27 import os.path | 27 import os.path |
28 from lxml import etree | 28 from lxml import etree |
29 from sat.tools import utils | 29 from sat.tools.common import date_utils |
30 | 30 |
31 | 31 |
32 PLUGIN_INFO = { | 32 PLUGIN_INFO = { |
33 C.PI_NAME: "Bugzilla import", | 33 C.PI_NAME: "Bugzilla import", |
34 C.PI_IMPORT_NAME: "IMPORT_BUGZILLA", | 34 C.PI_IMPORT_NAME: "IMPORT_BUGZILLA", |
66 root = etree.parse(file_path) | 66 root = etree.parse(file_path) |
67 | 67 |
68 for bug in root.xpath('bug'): | 68 for bug in root.xpath('bug'): |
69 ticket = {} | 69 ticket = {} |
70 ticket['id'] = bug.findtext('bug_id') | 70 ticket['id'] = bug.findtext('bug_id') |
71 ticket['created'] = utils.date_parse(bug.findtext('creation_ts')) | 71 ticket['created'] = date_utils.date_parse(bug.findtext('creation_ts')) |
72 ticket['updated'] = utils.date_parse(bug.findtext('delta_ts')) | 72 ticket['updated'] = date_utils.date_parse(bug.findtext('delta_ts')) |
73 ticket['title'] = bug.findtext('short_desc') | 73 ticket['title'] = bug.findtext('short_desc') |
74 reporter_elt = bug.find('reporter') | 74 reporter_elt = bug.find('reporter') |
75 ticket['author'] = reporter_elt.get('name') | 75 ticket['author'] = reporter_elt.get('name') |
76 if ticket['author'] is None: | 76 if ticket['author'] is None: |
77 if '@' in reporter_elt.text: | 77 if '@' in reporter_elt.text: |
101 body = longdesc.findtext('thetext') | 101 body = longdesc.findtext('thetext') |
102 else: | 102 else: |
103 who = longdesc.find('who') | 103 who = longdesc.find('who') |
104 comment = {'id': longdesc.findtext('commentid'), | 104 comment = {'id': longdesc.findtext('commentid'), |
105 'author_email': who.text, | 105 'author_email': who.text, |
106 'published': utils.date_parse(longdesc.findtext('bug_when')), | 106 'published': date_utils.date_parse(longdesc.findtext('bug_when')), |
107 'author': who.get('name', who.text), | 107 'author': who.get('name', who.text), |
108 'content': longdesc.findtext('thetext')} | 108 'content': longdesc.findtext('thetext')} |
109 comments.append(comment) | 109 comments.append(comment) |
110 | 110 |
111 ticket['body'] = body | 111 ticket['body'] = body |