Пример #1
0
def scrape(version, *, url, filter_pattern, all_versions=False, case_insensitive=False, **kwargs):
    data = fetch_page(url, **kwargs)

    versions = re.finditer(filter_pattern, data)
    versions = [match.group('version') for match in versions]

    # Apply user filters, change delimiter and sort
    versions = checkers.prepare_versions(versions, **kwargs)

    if len(versions) == 0:
        print("WARNING: no matching versions for {0}, pattern {1} with {2}".format(
            url, filter_pattern,
            checkers.describe_filter(**kwargs)))
        return True, 'none', "page URL: {0}".format(url)

    if case_insensitive:
        version = version.lower()
        versions = [version.lower() for version in versions]

    # On a webpage you may not have all versions so don't warn if not expected
    try:
        current_idx = versions.index(version)
    except ValueError:
        if all_versions:
            print("WARNING: version {3} not in versions for {0}, pattern {1} and with {2}".format(
                url, filter_pattern,
                checkers.describe_filter(**kwargs)), version)
        current_idx = -1

    latest = versions[0]

    return current_idx == 0, latest, "page URL: {0}".format(url)
Пример #2
0
def svn_tag(version, *, repository, **kwargs):
    parts = urlp.urlsplit(repository, allow_fragments=False)
    if parts.scheme.lower() == 'svn':
        names = svn_list_tags(repository)
    elif parts.scheme.lower() in ('http', 'https'):
        names = dav_list_tags(repository)
    else:
        raise Exception(
            "Scheme {0} not supported as SVN protocol for {1}".format(
                parts.scheme.lower(), repository))

    # Apply user filters, change delimiter and sort
    matching_tags = checkers.prepare_versions(names, **kwargs)

    if len(matching_tags) == 0:
        print("WARNING: no matching tags for {0} with {1}".format(
            repository, checkers.describe_filter(**kwargs)))
        return True, 'none', "repository URL: {0}".format(repository)

    try:
        current_idx = matching_tags.index(version)
    except ValueError:
        print(
            "WARNING: version {2} not in matched tags for {0} with {1}".format(
                repository, checkers.describe_filter(**kwargs)), version)
        current_idx = -1

    latest = matching_tags[0]

    return current_idx == 0, latest, "repository URL: {0}".format(repository)
Пример #3
0
def git_tag(version, *, repository, **kwargs):
    refs = fetch_refs(repository)

    matching_refs = list(refs.keys())

    refs = None

    # Remove refs/tag prefix
    matching_refs = checkers.filter_versions(matching_refs,
                                             prefix='refs/tags/')

    # Apply user filters, change delimiter and sort
    matching_refs = checkers.prepare_versions(matching_refs, **kwargs)

    if len(matching_refs) == 0:
        print("WARNING: no matching references for {0} with {1}".format(
            repository, checkers.describe_filter(**kwargs)))
        return True, 'none', "repository URL: {0}".format(repository)

    try:
        current_idx = matching_refs.index(version)
    except ValueError:
        print(
            "WARNING: version {2} not in matched references for {0} with {1}".
            format(repository, checkers.describe_filter(**kwargs), version))
        current_idx = -1

    latest = matching_refs[0]

    return current_idx == 0, latest, "repository URL: {0}".format(repository)
Пример #4
0
def hg_tag(version, *, repository, head="tip", context=None, **kwargs):
    refs = tags(repository, head, context)

    matching_refs = list(refs.keys())

    refs = None

    # Apply user filters, change delimiter and sort
    matching_refs = checkers.prepare_versions(matching_refs, **kwargs)

    if len(matching_refs) == 0:
        print("WARNING: no matching references for {0} with {1}".format(
            repository, checkers.describe_filter(**kwargs)))
        return True, 'none', "repository URL: {0}".format(repository)

    try:
        current_idx = matching_refs.index(version)
    except ValueError:
        print("WARNING: version {2} not in matched references for {0} with {1}".format(
            repository, checkers.describe_filter(**kwargs)),
            version)
        current_idx = -1

    latest = matching_refs[0]

    return current_idx == 0, latest, "repository URL: {0}".format(repository)