大家好,我有一个函数collect metrics,它基本上调用两个函数get\u open\u prs()和calculate\u warnings()
def collect_metrics():
"""function for collecting the desired metrics from github"""
for owner,repo in config.REPOS_TO_CHECK:
pulls_url = get_open_prs(owner,repo)
desired_github_metrics = calculate_warnings(pulls_url, config.TOO_OLD_DAYS)
desired_github_metrics["owner"] = owner
desired_github_metrics["repo"] = repo
print desired_github_metrics #prints dictionary
if __name__ == "__main__":
collect_metrics()
现在,我在打印collect\u metrics()时得到的输出是:
{'owner': 'owner', 'repo': 'test_repo', 'days': 7}
{'owner': 'owner1', 'repo': 'test_repo1', 'days': 17}
我要做的是返回所需的\u github \u度量,而不是打印它,我希望输出作为列表中的字典:
desired output:
[{'owner': 'owner', 'repo': 'test_repo', 'days': 7}]
[{'owner': 'owner1', 'repo': 'test_repo1', 'days': 17}]
所以当我调用collect\u metrics函数时:
if __name__ == '__main__':
data = collect_metrics()
for my data in data:
print(datum)
#prints output
[{'owner': 'owner', 'repo': 'test_repo', 'days': 7}]
[{'owner': 'owner1', 'repo': 'test_repo1', 'days': 17}]
目前没有回答
相关问题 更多 >
编程相关推荐