我目前使用的是 github3.py 版本 0.9.6,并且在调用github3.organization(login)函数时收到错误消息:
Traceback (most recent call last):
File "Main.py", line 23, in <module>
__main__()
File "Main.py", line 19, in __main__
Stats.git_auth(username, password, access_token)
File "/Users/edigiovine/Repositories/GitMetrics/Stats.py", line 36, in git_auth
git_orgs(gh)
File "/Users/edigiovine/Repositories/GitMetrics/Stats.py", line 49, in git_orgs
org = gh.organization(rel_org)
File "/Library/Python/2.7/site-packages/github3/github.py", line 971, in organization
return Organization(json, self) if json else None
File "/Library/Python/2.7/site-packages/github3/orgs.py", line 236, in __init__
super(Organization, self).__init__(org, session)
File "/Library/Python/2.7/site-packages/github3/models.py", line 311, in __init__
super(BaseAccount, self).__init__(acct, session)
File "/Library/Python/2.7/site-packages/github3/models.py", line 77, in __init__
super(GitHubCore, self).__init__(json)
File "/Library/Python/2.7/site-packages/github3/models.py", line 30, in __init__
self.etag = json.pop('ETag', None)
TypeError: pop() takes at most 1 argument (2 given)
我希望我能得到一些帮助来解决这个问题。具体来说,我很好奇上次通话中 None 来自哪里。
提前感谢您的帮助!
EDIT1:我正在尝试根据用户提供的现有组织列表调用特定组织,在我的情况下,该列表远小于组织的总列表,因此在这种情况下迭代所有组织对我没有好处(如果没有给出列表,这恰好是我的默认情况)。
再次感谢!
EDIT2:我正在实现的代码示例,显然微不足道(不能提供私人信息):
# Defined username, password, access_token, and api_call_base in a
# config file, use them here to build the github object.
gh = github3.login(username, password, access_token, api_call_base)
# predefined_orgs_list is a list of the names of the organizations
# that are in focus for my project.
for needed_org in predefined_orgs_list:
# This is the function that throws the error I am receiving.
org = gh.organization(needed_org)
# If above function works, then the following value should be
# the same as in the predefined_orgs_list
print org.login
EDIT3:我知道 gh.organization 函数是导致我的代码出现问题的原因,从堆栈跟踪可以看出。我的问题是关于 github3 的库,并询问我如何解决/修复 models.py 中的 pop() 函数,这是引发错误的函数。
EDIT4:感谢 pdb,我解决了这个问题:通过代码,我发现 url 生成是动态的,基于组织函数的输入。
具体来说,我所拥有的是我们组织的默认基本 URL,它正确收集了我们的组织数据。我需要做的是修改我的代码以使用两个不同的 url,基于获得组织列表与获取所有组织的条件。
此问题现已解决。感谢大家!