Exemplo n.º 1
0
for repo in repolist:
    pageNum = 1
    print("\n'%s'" % (repo))
    print(tab + "page " + str(pageNum))

    repoSplit = repo.split("/")

    print(tab + "Modifying query...")
    newqueryRep = re.sub('OWNNAME', repoSplit[0], query_in)
    newqueryRep = re.sub('REPONAME', repoSplit[1], newqueryRep)
    newquery = re.sub(' PGCURS', '', newqueryRep)
    gitquery = json.dumps({'query': newquery})
    print(tab + "Query ready!")

    # Actual query exchange
    outObj = helpers.query_github(authhead, gitquery)
    if outObj["errors"]:
        print(tab + "Could not complete '%s'" % (repo))
        collective["data"].pop(repo, None)
        continue
    # Update collective data
    collective["data"][repo] = outObj["data"]["repository"]

    # Paginate if needed
    hasNext = outObj["data"]["repository"]["repositoryTopics"]["pageInfo"][
        "hasNextPage"]
    while hasNext:
        pageNum += 1
        print(tab + "page %d" % (pageNum))
        cursor = outObj["data"]["repository"]["repositoryTopics"]["pageInfo"][
            "endCursor"]
	pageNum = 1
	print("\n'%s'" % (repo))
	print(tab + "page %d" % (pageNum))

	repoSplit = repo.split("/")

	# Query 1
	print(tab + "Get creation date and default branch")
	print(tab + "Modifying query...")
	newquery = re.sub('OWNNAME', repoSplit[0], query_in)
	newquery = re.sub('REPONAME', repoSplit[1], newquery)
	gitquery = json.dumps({'query': newquery})
	print(tab + "Query ready!")

	# Actual query exchange
	outObj = helpers.query_github(authhead, gitquery)
	if outObj["errors"]:
		print(tab + "Could not complete '%s'" % (repo))
		collective["data"].pop(repo, None)
		continue

	# Update collective data
	collective["data"][repo] = outObj["data"]["repository"]

	# Query 2
	print(tab + "Get pre-GitHub commit timestamps")
	print(tab + "Modifying query...")
	gitquery = re.sub('OWNNAME', repoSplit[0], query_commits_in)
	gitquery = re.sub('REPONAME', repoSplit[1], gitquery)
	gitquery = re.sub('CREATETIME', collective["data"][repo]["createdAt"], gitquery)
	print(tab + "Query ready!")