def detect(cls, name, url, **kwargs):
urlp = urllib.parse.urlparse(url)
if urlp.netloc != 'github.com':
return
pathseg = urlp.path.lstrip('/').split('/')
if pathseg[0] == 'downloads':
pathseg.pop(0)
repo = '/'.join(pathseg[:2])
if repo.endswith('.git'):
repo = repo[:-4]
if len(pathseg) > 2:
if pathseg[2] == 'releases':
return cls(name, repo, 'release')
elif pathseg[2] == 'tags':
return cls(name, repo, 'tag')
elif pathseg[2] == 'commits':
return cls(name, repo, 'commit', pathseg[3])
for category, url in (
('release', 'https://github.com/%s/releases.atom' % repo),
('tag', 'https://github.com/%s/tags.atom' % repo),
('commit', 'https://github.com/%s/commits/master.atom' % repo)):
feed = feedparser.parse(url)
if feed.entries:
return cls(name, repo, category)
评论列表
文章目录