__init__.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:github-stars-by-topic 作者: lorey 项目源码 文件源码
def fetch_readme(repo):
    cache_key = str(repo.id)
    cache_file = CACHE_PATH_READMES + os.sep + cache_key

    # check if file is cached
    if os.path.isfile(cache_file):
        with open(cache_file, 'r') as file:
            return file.read()

    # create cache folder
    if not os.path.isdir(CACHE_PATH_READMES):
        os.mkdir(CACHE_PATH_READMES)

    try:
        readme = repo.get_readme()
    except github.GithubException:
        # Readme wasn't found
        logging.warning('no readme found for: ' + repo.full_name)
        return ''

    return readme.content
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号