MCPcopy Index your code
hub / github.com/EvanLi/Github-Ranking / write_ranking_repo

Function write_ranking_repo

source/common.py:22–36  ·  view source on GitHub ↗
(file_name, method, repos)

Source from the content-addressed store, hash-verified

20
21
22def write_ranking_repo(file_name, method, repos):
23 # method: 'a'-append or 'w'-overwrite
24 table_head = "| Ranking | Project Name | Stars | Forks | Language | Open Issues | Description | Last Commit |\n\
25| ------- | ------------ | ----- | ----- | -------- | ----------- | ----------- | ----------- |\n"
26 with open(file_name, method, encoding='utf-8') as f:
27 f.write(table_head)
28 for idx, repo in enumerate(repos):
29 repo_description = repo['description']
30 if repo_description is not None:
31 repo_description = repo_description.replace('|', '\|') # in case there is '|' in description
32 f.write("| {} | [{}]({}) | {} | {} | {} | {} | {} | {} |\n".format(
33 idx + 1, repo['name'], repo['html_url'], repo['stargazers_count'], repo['forks_count'],
34 repo['language'], repo['open_issues_count'], repo_description, repo['pushed_at']
35 ))
36 f.write('\n')
37
38
39def get_api_repos(API_URL):

Callers 1

write_readme_lang_mdMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected