in project.py [0:0]
def _append_item_to_project(self, item):
# todo assignee
closed = str(item.statusCategory.get('id')) == self.doneStatusCategoryId
closed_at = ''
if closed:
try:
closed_at = self._convert_to_iso(item.resolved.text)
except AttributeError:
pass
# TODO: ensure item.assignee/reporter.get('username') to avoid "JENKINSUSER12345"
# TODO: fixit in gh issues
# check if issue description is missing or empty and set a default
if not hasattr(item, 'description') or not item.description:
item.description = 'No Description'
body = self._htmlentitydecode(item.description.text)
# metadata: original author & link
body = body + '\n\n---\n<details><summary><i>Originally reported by <a title="' + str(item.reporter) + '" href="' + self.jiraBaseUrl + '/secure/ViewProfile.jspa?name=' + item.reporter.get('username') + '">' + item.reporter.get('username') + '</a>, imported from: <a href="' + self.jiraBaseUrl + '/browse/' + item.key.text + '" target="_blank">' + item.title.text[item.title.text.index("]") + 2:len(item.title.text)] + '</a></i></summary>'
# metadata: assignee
body = body + '\n<i><ul>'
if item.assignee != 'Unassigned':
body = body + '\n<li><b>assignee</b>: <a title="' + str(item.assignee) + '" href="' + self.jiraBaseUrl + '/secure/ViewProfile.jspa?name=' + item.assignee.get('username') + '">' + item.assignee.get('username') + '</a>'
try:
body = body + '\n<li><b>status</b>: ' + item.status
except AttributeError:
pass
try:
body = body + '\n<li><b>priority</b>: ' + item.priority
except AttributeError:
pass
try:
body = body + '\n<li><b>resolution</b>: ' + item.resolution
except AttributeError:
pass
try:
body = body + '\n<li><b>resolved</b>: ' + self._convert_to_iso(item.resolved.text)
except AttributeError:
pass
body = body + '\n<li><b>imported</b>: ' + datetime.today().strftime('%Y-%m-%d')
body = body + '\n</ul></i>\n</details>'
# retrieve jira components and labels as github labels
labels = []
# set a default component if empty or missing
if not hasattr(item, 'component') or not item.component:
item.component = 'miscellaneous'
for component in item.component:
if os.getenv('JIRA_MIGRATION_INCLUDE_COMPONENT_IN_LABELS', 'true') == 'true':
labels.append('jira-component:' + component.text.lower())
labels.append(component.text.lower())
print("Debug: component.text.lower = {component.text.lower()}")
if not hasattr(item, 'labels') or not item.labels:
pass
else:
labels.append(self._jira_type_mapping(item.type.text.lower()))
for label in item.labels.findall('label'):
converted_label = convert_label(label.text.strip().lower(), self.labels_mapping, self.approved_labels)
if converted_label is not None:
labels.append(converted_label)
labels.append('imported-jira-issue')
unique_labels = list(set(labels))
self._project['Issues'].append({'title': item.title.text,
'key': item.key.text,
'body': body,
'created_at': self._convert_to_iso(item.created.text),
'closed_at': closed_at,
'updated_at': self._convert_to_iso(item.updated.text),
'closed': closed,
'labels': unique_labels,
'comments': [],
'duplicates': [],
'is-duplicated-by': [],
'is-related-to': [],
'depends-on': [],
'blocks': []
})
if not self._project['Issues'][-1]['closed_at']:
del self._project['Issues'][-1]['closed_at']