给定一个分叉的仓库,我如何使用github3.py来查找它所分叉的父仓或上游仓库?对于请求,这相当容易,但我无法弄清楚如何在github3.py中执行此操作。
请求:
for repo in gh.repositories_by(username): # github3.py provides a user's repos
if repo.fork: # we only care about forked repos
assert 'parent' not in repo.as_dict() # can't find parent using github3.py
repo_info = requests.get(repo.url).json() # try with requests instead
assert 'parent' in repo_info, repo_info # can find parent using requests
print(f'{repo_info["url"]} was forked from {repo_info["parent"]["url"]}')
# https://github.com/username/repo was forked from
# https://github.com/parent/repo
此用例类似于How can I find all public repos in github that a user contributes to?,但我们还需要检查用户的repo分叉的父/上游repo。
答案 0 :(得分:1)
文档显示它存储为repo.parent,但只能在value = list()
for(i in 1:1000){
x=sample(1:500,30,replace=F)
mhat=stimateM=2*mean(x)-1
y=abs(mhat-500)
value[i]=y
}
sumValue = sum(unlist(value))
divValue = sumValue/1000
个对象上使用。 Repository
会返回repositories_by
个对象。
这看起来像是:
ShortRepository