Access specific information within worklogs in jira-python

时光怂恿深爱的人放手 提交于 2019-11-29 14:38:47

I found a roundabout way of doing it through the client.

As I iterate through each issue I get the list of worklogs per ticket by doing worklogs = jira_client.worklogs(issue.key) and then i iterate through all of the worklog items in the worklogs list (a nested for loop):

for worklog in worklogs:
    totaltime += readtime(worklog.timeSpent)

Using the jirashell I accessed a specific worklog of a specific ticket: wl = jira_client.worklog(<issue key>, <worklog id>) then I typed in wl. and pressed TAB, it listed the following:

wl.author, wl.comment, wl.created, wl.delete, wl.find, wl.id, wl.raw, wl.self, wl.started, wl.timeSpent, wl.timeSpentSeconds, wl.update, wl.updateAuthor, wl.updated

(Note: you need to include the period at the end of wl before pressing tab)

Running wl.timespent in the jirashell gave me gave me a unicode string with the number and then h or m for hour or minute (for example: u'6h'). Then I new that once I generated the worklog object in my loop above, I could access the time by using the timepsent attribute.

(Note: My readtime function turns the string into an integer and converts hours to minutes, and is not shown here)

The jirashell really helps with trying to find the attributes of the fields, etc. (Note: you need to install jira-python in addition to jira in order to run jirashell. Also if you installed jira-python in your virtualenv you need to run env/bin/jirashell from your command line once you are in your project's directory.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!