如何在jira-python中找到提供的字段

时间:2014-09-18 14:35:21

标签: python jira

我有一个类可以完成查找PR等所有任务。

我有一个方法:

class myJiraClass:    
    def return_supplied_field(self, issue, field_name):
        """ Essentially I need to return issue.fields.field_name here """

test = myJiraClass();    
issue = test.find_issue("IL-1010")
summary = test.return_supplied_field(issue, "summary")
print summary

我该怎么做?

我希望此函数只返回字段值,如:

1 个答案:

答案 0 :(得分:1)

您可以使用getattr()动态查找属性:

def return_supplied_field(self, issue, field_name):
    """ Essentially I need to return issue.fields.field_name here """
    return getattr(issue.fields, field_name)