Several enhancements
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# find comments with estimations out of pre-planning
|
||||
# zisco 2021-09-30 19:50
|
||||
# TODO: Consider later created sub-tasks
|
||||
|
||||
from multiprocessing.sharedctypes import Value
|
||||
from types import ClassMethodDescriptorType
|
||||
from jira import JIRA, Issue, Comment, exceptions
|
||||
import re
|
||||
import csv
|
||||
import xlsxwriter
|
||||
import logging
|
||||
import yaml
|
||||
from bisect import bisect_left
|
||||
from datetime import date
|
||||
|
||||
|
||||
logging.basicConfig(filename='sub_task_generator.log',
|
||||
filemode='a',
|
||||
format='%(asctime)s - %(levelname)s: %(message)s',
|
||||
level=logging.INFO,
|
||||
encoding='utf-8')
|
||||
|
||||
with open("config.yaml", encoding='utf8') as f:
|
||||
cfg = yaml.load(f, Loader=yaml.FullLoader)
|
||||
|
||||
host = "https://jira.wien.gv.at/"
|
||||
pat = "OTAyMTM3MjY0MjE0Ovz6bu0ti1TlEdSegmmiWiJ2wGeD"
|
||||
headers = JIRA.DEFAULT_OPTIONS["headers"].copy()
|
||||
headers["Authorization"] = f"Bearer {pat}"
|
||||
jira_server = JIRA(server=host, options={"headers": headers})
|
||||
|
||||
# use filter or single issue
|
||||
issues_Jql = jira_server.search_issues('filter=31528') #, expand='changelog')
|
||||
logging.info(f"Modify 'DoD SA' sub-tasks with link to Dev sub-tasks")
|
||||
|
||||
issue: Issue
|
||||
for issue in issues_Jql:
|
||||
logging.info('Working on {}'.format(issue))
|
||||
|
||||
# else:
|
||||
# single_issue = jira_server.issue(issue.key)
|
||||
|
||||
# find corresponding Dev sub-tasks
|
||||
#escaped = issue.fields.summary.replace('"', r'\"')
|
||||
#escaped = escaped.replace('[DoD SA]', '').strip()
|
||||
escaped = issue.fields.summary.replace('[DoD SA]', '').strip()
|
||||
logging.info(f'summary ~ \"{escaped}\"')
|
||||
|
||||
description = issue.fields.description
|
||||
links_section = '\r\n||Dev-Links||Typ||'
|
||||
position = description.find(links_section)
|
||||
if position != -1:
|
||||
# clear list
|
||||
description = description[:position + len(links_section)].strip()
|
||||
else:
|
||||
description += links_section
|
||||
|
||||
for type in ['Backend','Frontend']:
|
||||
subtask = jira_server.search_issues(f'summary ~ \"Dev {type} {escaped}\"')
|
||||
if subtask:
|
||||
# adapt DoD SA-desc
|
||||
description += "\r\n|" + subtask[0].key + f'|{type}|'
|
||||
|
||||
try:
|
||||
issue.update(fields={'description': description})
|
||||
except Exception as e:
|
||||
logging.info(e)
|
||||
|
||||
logging.info(f'Link to {type} for {issue} created')
|
||||
Reference in New Issue
Block a user