Find custom list_urls depending on the archive URL (e.g. github releases)
This commit is contained in:
parent
2de2d4bea7
commit
608191bd8c
@ -859,7 +859,7 @@ def find_versions_of_archive(archive_url, **kwargs):
|
|||||||
list_depth = kwargs.get('list_depth', 1)
|
list_depth = kwargs.get('list_depth', 1)
|
||||||
|
|
||||||
if not list_url:
|
if not list_url:
|
||||||
list_url = os.path.dirname(archive_url)
|
list_url = url.find_list_url(archive_url)
|
||||||
|
|
||||||
# This creates a regex from the URL with a capture group for the
|
# This creates a regex from the URL with a capture group for the
|
||||||
# version part of the URL. The capture group is converted to a
|
# version part of the URL. The capture group is converted to a
|
||||||
|
@ -78,6 +78,26 @@ def __init__(self, path):
|
|||||||
"Couldn't parse package name in: " + path, path)
|
"Couldn't parse package name in: " + path, path)
|
||||||
|
|
||||||
|
|
||||||
|
def find_list_url(url):
|
||||||
|
"""Finds a good list URL for the supplied URL. This depends on
|
||||||
|
the site. By default, just assumes that a good list URL is the
|
||||||
|
dirname of an archive path. For github URLs, this returns the
|
||||||
|
URL of the project's releases page.
|
||||||
|
"""
|
||||||
|
|
||||||
|
url_types = [
|
||||||
|
# e.g. https://github.com/scalability-llnl/callpath/archive/v1.0.1.tar.gz
|
||||||
|
(r'^(https://github.com/[^/]+/[^/]+)/archive/', lambda m: m.group(1) + '/releases')
|
||||||
|
]
|
||||||
|
|
||||||
|
for pattern, fun in url_types:
|
||||||
|
match = re.search(pattern, url)
|
||||||
|
if match:
|
||||||
|
return fun(match)
|
||||||
|
else:
|
||||||
|
return os.path.dirname(url)
|
||||||
|
|
||||||
|
|
||||||
def parse_version_string_with_indices(path):
|
def parse_version_string_with_indices(path):
|
||||||
"""Try to extract a version string from a filename or URL. This is taken
|
"""Try to extract a version string from a filename or URL. This is taken
|
||||||
largely from Homebrew's Version class."""
|
largely from Homebrew's Version class."""
|
||||||
|
Loading…
Reference in New Issue
Block a user