码迷,mamicode.com
首页 > 其他好文 > 详细

【Py-Github】根据条件筛选repo的例子

时间:2017-12-05 18:55:10      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:==   exception   final   one   实现   hub   repo   根据   nal   

条件:

language:python
commits:>100
contributors:>2
stars:>5
fork:0

 

实现:

from github import Github

access_token = your_token
gh = Github(access_token)

def search_repositories(q):
    try:
        repos=gh.search_repositories(query=q)
    except Exception, e:
        return None
    return repos


if __name__ == __main__:
    q = "language:Python forks:0 stars:>5"
    repos=search_repositories(q)
    min_num_of_commits=100
    min_num_of_contributors = 2
    final_repos=[]
    for repo in repos:
        num_of_commits=len(list(repo.get_commits()))
        num_of_contributors=len(list(repo.get_contributors()))
        if num_of_commits>min_num_of_commits and num_of_contributors>min_num_of_contributors:
            final_repos.append(repo)
            print name : , repo.name
            print html_url : , repo.html_url
            print url : , repo.url
            print #commits : , num_of_commits
            print #contributors : , num_of_contributors

 

【Py-Github】根据条件筛选repo的例子

标签:==   exception   final   one   实现   hub   repo   根据   nal   

原文地址:http://www.cnblogs.com/XBWer/p/7988599.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!