base.py 文件源码

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

项目:verse 作者: pawelad 项目源码 文件源码
def _get_github_tags(self, github_url=None, normalize_func=None):
        """
        Yields GitHub tag names, serialized to `Version` object

        :param github_url: project GitHub repository URL
        :type github_url: str
        :param normalize_func: function that normalizes tag name
        :type normalize_func: callable
        :returns: generator of project versions
        :rtype: generator of packaging.version.Version
        :raises ValueError: when passed URL is not a GitHub repository
        """
        if not github_url:
            github_url = self.repository

        owner, name = deconstruct_github_url(github_url)
        tags = github_client.repository(owner, name).iter_tags()
        for tag in tags:
            if normalize_func:
                name = normalize_func(tag.name)
            else:
                name = tag.name

            # Add a minor version if it's not there, i.e. v1 -> v1.0
            if name and len(name.split('.')) == 1:
                name += '.0'

            try:
                version = Version(name)
            except InvalidVersion:
                continue

            yield version
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号