2017-01-06 67 views
1

我目前使用github3.py版本0.9.6,并且在调用时收到错误github3.organization(login) function :github3 0.9.6 TypeError:pop()至多需要1个参数(给出2个)

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,基于给出组织列表的条件与抓住所有组织。

现在已解决此问题。感谢大家!

+1

你能提供一个代码吗? – soundslikeodd

+1

给予一行代码和回溯将无济于事。什么是“登录”? – Leb

+3

看起来像是在预计字典中出现一个列表。 – user2357112

回答

2

问题在于你的org = gh.organization(needed_org)行。显然.organization()方法使用pop。无论predefined_orgs_list变量可能是什么,看起来像某种列表(从名字......杜)的某种。

但是,从上面的链接,pop需要一个索引不是一个项目。这个回答Difference between del, remove and pop on lists显示了pop用于什么并将其与其他方法进行比较的一个很好的例子。

相关问题