本文整理汇总了Python中jira.JIRA.worklog方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.worklog方法的具体用法?Python JIRA.worklog怎么用?Python JIRA.worklog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.worklog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import worklog [as 别名]
class JiraLogger:
def __init__(self):
warnings.filterwarnings('ignore') # SNIMissingWarning and InsecurePlatformWarning is printed everytime a query is called. This is just to suppress the warning for a while.
try:
self.params = self.__get_params_from_config()
self.jira = JIRA(server=self.params['server'], basic_auth=(self.params['username'], self.params['password']));
except JIRAError:
raise RuntimeError("Something went wrong in connecting to JIRA. Please be sure that your server, username and password are filled in correctly.")
else:
# self.__log_work_for_sprint()
self.populate_dict()
def populate_dict(self):
print 'Fetching data from JIRA server. This will take a while...'
issues = self.__fetch_all_issues_for_project()
issues = self.__filter_resolved_and_closed_issues(issues)
self.__fetch_all_worklogs_for_issues(issues)
self.__filter_worklogs_not_for_this_sprint(issues)
self.__filter_worklogs_not_from_user(issues)
# pretty = prettify.Prettify()
# print pretty(self.__get_total_timespent_per_day_of_sprint(issues))
def __fetch_all_issues_for_project(self):
return self.jira.search_issues('project={}'.format(self.params['project']), maxResults=False)
# TODO: move formatting to another function
def __filter_resolved_and_closed_issues(self, issues):
filtered_issues = {}
for issue in issues:
if not (str(issue.fields.status) == 'Resolved' or str(issue.fields.status) == 'Closed'):
filtered_issues[issue.id] = {
'key': issue.key,
'summary': issue.fields.summary,
'assignee': issue.fields.assignee,
'reporter': issue.fields.reporter,
'status': issue.fields.status.name,
'issuetype': issue.fields.issuetype.name,
'subtasks': [subtask.id for subtask in issue.fields.subtasks],
'worklogs': [worklog.id for worklog in self.jira.worklogs(issue.id)]
}
return filtered_issues
def __fetch_all_worklogs_for_issues(self, issues):
for issue_id, issue_details in issues.items():
worklogs_list = {}
for worklog_id in issue_details['worklogs']:
worklogs_list.update(self.__fetch_worklog_details(issue_id, worklog_id))
issue_details['worklogs'] = worklogs_list
return issues
# TODO: move formatting to another function
def __fetch_worklog_details(self, issue_id, worklog_id):
worklog = self.jira.worklog(issue_id, worklog_id)
return {
worklog.id: {
'author': worklog.author,
'date': datetime.strptime(worklog.started[:10], '%Y-%m-%d').strftime('%Y-%m-%d'),
'timespent': worklog.timeSpent,
'comment': worklog.comment
}
}
def __filter_worklogs_not_for_this_sprint(self, issues):
sprint_dates = self.__get_start_and_end_date_for_sprint()
dates = self.__generate_date_list(sprint_dates[0], sprint_dates[1])
for issue_id, issue_details in issues.items():
for worklog_id, worklog_details in issue_details['worklogs'].items():
if worklog_details['date'] not in dates:
del issue_details['worklogs'][worklog_id]
def __filter_worklogs_not_from_user(self, issues):
for issue_id, issue_details in issues.items():
for worklog_id, worklog_details in issue_details['worklogs'].items():
if not worklog_details['author'].name == self.username:
del issue_details['worklogs'][worklog_id]
def __get_total_timespent_per_day_of_sprint(self, issues):
sprint_dates = self.__get_start_and_end_date_for_sprint()
dates = self.__generate_date_list(sprint_dates[0], sprint_dates[1])
worklogs = {}
for date in dates:
worklogs[date] = []
for issue_id, issue_details in issues.items():
for worklog_id, worklog_details in issue_details['worklogs'].items():
worklogs[worklog_details['date']].append(worklog_details['timespent'])
return {date: helper.to_time(sum(map(helper.parse_time, timespent))) for date, timespent in worklogs.items()}
# REMOVE: FRONTEND
def __get_start_and_end_date_for_sprint(self):
sprint_dates = {
#.........这里部分代码省略.........