github3仓储内容返回一个空对象 。

2024-05-05 00:23:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我想得到它存储的文件的内容。你知道吗

我使用以下代码:

repos = [f for f in gh.iter_user_repos(git_org, branch)]
modules = {}
modules_infos = {}
for a in repos:
    # get the list folder in repo
    if not a or not a.contents('.', branch):
        continue
    # get the list modules in each folder
    for cont in a.contents('.', branch).iteritems():
        if '.' not in cont[0] and cont[0] not in EXCEPTION_FOLDER:
            modules.update({cont[1].name: cont[1].html_url})
            if not cont[1] or not a.contents(cont[1].name, branch):
                continue
            for sub_folder in a.contents(cont[1].name, branch).iteritems():
                if sub_folder[0] == 'configurations.txt':
                    vals = eval(base64.b64decode(sub_folder[1].content))
                    modules_infos.update({cont[1].name: [vals.get('name', False),
                                                         vals.get('version', False),]})

但是,sub_folder[1].content是空的,我无法得到我的信息。 我错过什么了吗?你知道吗


Tags: thenameinbranchmodulesforgetif