Exemple #1
0
def find_versions_of_archive(archive_url, **kwargs):
    list_url   = kwargs.get('list_url', None)
    list_depth = kwargs.get('list_depth', 1)
    wildcard   = kwargs.get('wildcard', None)

    if not list_url:
        list_url = os.path.dirname(archive_url)
    if not wildcard:
        wildcard = url.parse_version(archive_url).wildcard()

    versions = VersionList()
    url_regex = os.path.basename(url.wildcard_version(archive_url))

    page_map = get_pages(list_url, depth=list_depth)

    for site, page in page_map.iteritems():
        strings = re.findall(url_regex, page)

        for s in strings:
            match = re.search(wildcard, s)
            if match:
                v = match.group(0)
                versions.add(Version(v))

    return versions
Exemple #2
0
 def default_version(self):
     """Get the version in the default URL for this package,
        or fails."""
     try:
         return url.parse_version(self.__class__.url)
     except UndetectableVersionError:
         tty.die("Couldn't extract a default version from %s. You " +
                 "must specify it explicitly in the package." % self.url)