chores.py 文件源码

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

项目:piss 作者: AOSC-Dev 项目源码 文件源码
def detect(cls, name, url, **kwargs):
        urlp = urllib.parse.urlparse(url)
        if urlp.netloc != 'bitbucket.org':
            return
        pathseg = urlp.path.lstrip('/').split('/')
        repo = '/'.join(pathseg[:2])
        if repo.endswith('.git'):
            repo = repo[:-4]
        if len(pathseg) > 2:
            if pathseg[2] == 'downloads':
                return cls(name, repo, 'release')
            elif pathseg[2] == 'get':
                return cls(name, repo, 'tag')
        for category, url in (
            ('release', 'https://api.bitbucket.org/2.0/repositories/%s/downloads' % repo),
            ('tag', 'https://api.bitbucket.org/2.0/repositories/%s/refs/tags' % repo)):
            req = HSESSION.get(url, timeout=30)
            if req.status_code == 200:
                d = req.json()
                if d.get('values'):
                    return cls(name, repo, category)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号