I'm creating a json data source for Grafana in Python. It will grab information from JIRA and present is as a table to Grafana. I want the creation of the table to be dynamic so I want to be able to dynamically assign the fields I grab. The only way I've found that works so far is using eval()
...
Can someone point me to a better solution? I've looked at getattr
and setattr
but either I don't understand how to use it or it doesn't do what I need..
Below example uses it only for priority
:
priority = 'issue.fields.priority.name'
for issue in self.jira.search_issues(jql, maxResults=False):
if issue.fields.assignee:
issuelist.append([issue.key, issue.fields.assignee.displayName, eval(priority)])
else:
issuelist.append([issue.key, 'Unassigned', eval(priority)])