我一直在尝试使用Python API for JIRA(喜欢它),并且发现使用jira.issue而不是jira.search_issues时返回的内容不一致
例如,我有这个简单的代码,它找到父母关闭的所有开放子任务:
from jira import JIRA
import re
jira_options = {
'server': 'http://myserver:8081/jira'
}
jira = JIRA(options=jira_options, basic_auth=('dwaynek','bigsecret'))
issues = jira.search_issues('issuetype=Sub-task and status!=Closed and project=proj1 order by assignee')
for i in issues:
parentIssue = jira.issue(i.fields.parent)
print("\t- parent issue %s is %s" % (i.fields.parent, parentIssue.fields.status.name))
print("Verifying %s subtask %s assigned to %s"%(i.fields.status,i, i.fields.assignee.name))
# print for debugging
print(dir(parentIssue.fields))
print(dir(i.fields))
print("\t- parent %s is %s and was assigned to %s" % (i.fields.parent, parentIssue.fields.status.name, parentIssue.fields.assignee.name))
产生输出,并出现如下错误:
- parent issue BUG-19834 is Closed
Verifying Open subtask BUG-19836 assigned to andreas
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'issuetype', 'priority', 'status', 'summary']
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'aggregateprogress', 'aggregatetimeestimate', 'aggregatetimeoriginalestimate', 'aggregatetimespent', 'assignee', 'components', 'created', 'creator', 'customfield_10000', 'customfield_10001', 'customfield_10002', 'customfield_10006', 'customfield_10100', 'customfield_10102', 'customfield_10103', 'customfield_10105', 'customfield_10106', 'customfield_10107', 'customfield_10108', 'customfield_10109', 'customfield_10110', 'customfield_10111', 'customfield_10202', 'customfield_10300', 'customfield_10301', 'customfield_10302', 'customfield_10400', 'customfield_10500', 'customfield_10600', 'customfield_10601', 'customfield_10602', 'customfield_10700', 'customfield_10900', 'customfield_11000', 'description', 'fixVersions', 'issuelinks', 'issuetype', 'labels', 'lastViewed', 'parent', 'priority', 'progress', 'project', 'reporter', 'resolution', 'resolutiondate', 'status', 'subtasks', 'summary', 'timeestimate', 'timeoriginalestimate', 'timespent', 'updated', 'versions', 'watches', 'workratio']
Traceback (most recent call last):
File "find_closed_parents.py", line 25, in <module>
print("\t- parent %s is %s and was assigned to %s" % (i.fields.parent, parentIssue.fields.status.name, parentIssue.fields.assignee.name))
AttributeError: type object 'PropertyHolder' has no attribute 'assignee'
注意:我收到的词典包含不同的元素。从search_issues收到的dict似乎返回的属性远多于从jira.issue()
收到的属性。这是为什么?我甚至尝试在jira.issue()的调用中指定字段而没有运气。
我错过了什么?