6

我正在使用github3 python 库,并试图找到我们组织的用户贡献的所有公共存储库(以奖励对开源的支持!)。
我有组织的用户列表,但现在呢?
我可以使用公共事件迭代器来查找存储库吗?

#!/usr/bin/env python
import argparse
import github3


def get_organization(github, name):
    for organization in github.iter_orgs():
        if organization.login == name:
            return organization


def main(args):
    github = github3.login(args.github_username, password=args.github_password)
    organization = get_organization(github, args.organization)

    # Get a list of all current organization contributors
    orgMembers = [member.login for member in organization.iter_members()]

# now what?  
4

1 回答 1

2

你可以举一个 test_github.py的例子:

def test_iter_user_repos(self):
    self.response('repo', _iter=True)
    self.get('https://api.github.com/users/sigmavirus24/repos')
    self.conf.update(params={'type': 'all', 'direction': 'desc'})

    next(self.g.iter_user_repos('sigmavirus24', 'all', direction='desc'))
    self.mock_assertions()

    self.conf.update(params={"sort": "created"})
    self.get('https://api.github.com/users/sigmavirus24/repos')

    assert isinstance(next(self.g.iter_user_repos('sigmavirus24', sort="created")),
                      github3.repos.Repository)
    self.mock_assertions()

它基于“如何检索一个人的所有 github 仓库列表? ”中提到的GitHub API

/users/:user/repos

(仅限公共回购)

于 2013-09-10T05:29:58.077 回答