Mercurial > libervia-backend
comparison src/plugins/plugin_tickets_import_bugzilla.py @ 2390:f57a8eaec8ed
plugins import, tickets import, bugzilla import: comments handling:
- comments are put in "comments" key in import data, it's a list of microblog data
- in resulting item, the comments uri is put in comments_uri field
- (plugin import) root_service and root_node are kept in session
- (plugin ticket) reporter name is now in "reporter" key instead of "reporter_name"
- (plugin bugizlla): if not reporter name is found, first part of email address is used
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 20 Oct 2017 08:48:41 +0200 |
parents | a49a19f06e38 |
children | acfc481629ac |
comparison
equal
deleted
inserted
replaced
2389:5675af905725 | 2390:f57a8eaec8ed |
---|---|
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 | 30 |
30 | 31 |
31 PLUGIN_INFO = { | 32 PLUGIN_INFO = { |
32 C.PI_NAME: "Bugzilla import", | 33 C.PI_NAME: "Bugzilla import", |
33 C.PI_IMPORT_NAME: "IMPORT_BUGZILLA", | 34 C.PI_IMPORT_NAME: "IMPORT_BUGZILLA", |
69 ticket['id'] = bug.findtext('bug_id') | 70 ticket['id'] = bug.findtext('bug_id') |
70 ticket['creation'] = bug.findtext('creation_ts') | 71 ticket['creation'] = bug.findtext('creation_ts') |
71 ticket['update'] = bug.findtext('delta_ts') | 72 ticket['update'] = bug.findtext('delta_ts') |
72 ticket['title'] = bug.findtext('short_desc') | 73 ticket['title'] = bug.findtext('short_desc') |
73 reporter_elt = bug.find('reporter') | 74 reporter_elt = bug.find('reporter') |
74 ticket['reporter_name'] = reporter_elt.get('name') | 75 ticket['reporter'] = reporter_elt.get('name') |
76 if ticket['reporter'] is None: | |
77 if '@' in reporter_elt.text: | |
78 ticket['reporter'] = reporter_elt.text[:reporter_elt.text.find('@')].title() | |
79 else: | |
80 ticket['reporter'] = u'no name' | |
75 ticket['reporter_email'] = reporter_elt.text | 81 ticket['reporter_email'] = reporter_elt.text |
76 assigned_to_elt = bug.find('assigned_to') | 82 assigned_to_elt = bug.find('assigned_to') |
77 ticket['assigned_to_name'] = assigned_to_elt.get('name') | 83 ticket['assigned_to_name'] = assigned_to_elt.get('name') |
78 ticket['assigned_to_email'] = assigned_to_elt.text | 84 ticket['assigned_to_email'] = assigned_to_elt.text |
79 ticket['cc_emails'] = [e.text for e in bug.findall('cc')] | 85 ticket['cc_emails'] = [e.text for e in bug.findall('cc')] |
93 for longdesc in bug.findall('long_desc'): | 99 for longdesc in bug.findall('long_desc'): |
94 if body is None: | 100 if body is None: |
95 body = longdesc.findtext('thetext') | 101 body = longdesc.findtext('thetext') |
96 else: | 102 else: |
97 who = longdesc.find('who') | 103 who = longdesc.find('who') |
98 comment = {'from': who.text, | 104 comment = {'id': longdesc.findtext('commentid'), |
99 'date': longdesc.findtext('bug_when'), | 105 'author_email': who.text, |
100 'nick': who.get('name'), | 106 'published': utils.date_parse(longdesc.findtext('bug_when')), |
101 'body': longdesc.findtext('thetext')} | 107 'author': who.get('name', who.text), |
108 'content': longdesc.findtext('thetext')} | |
102 comments.append(comment) | 109 comments.append(comment) |
103 | 110 |
104 ticket['body'] = body | 111 ticket['body'] = body |
105 ticket['comments'] = comments | 112 ticket['comments'] = comments |
106 tickets.append(ticket) | 113 tickets.append(ticket) |