Example #1
0
 def mk_uri_list(*iterable, **kwds):
     filename = kwds.get("filename", "asdf")
     obj = fetch.uri_list(filename)
     for x in iterable:
         if isinstance(x, fetch.mirror):
             obj.add_mirror(x)
         else:
             obj.add_uri(x)
     return obj
Example #2
0
 def mk_uri_list(*iterable, **kwds):
     filename = kwds.get("filename", "asdf")
     obj = fetch.uri_list(filename)
     for x in iterable:
         if isinstance(x, fetch.mirror):
             obj.add_mirror(x)
         else:
             obj.add_uri(x)
     return obj
Example #3
0
def create_fetchable_from_uri(pkg,
                              chksums,
                              ignore_missing_chksums,
                              ignore_unknown_mirrors,
                              mirrors,
                              default_mirrors,
                              common_files,
                              uri,
                              filename=None):
    default_filename = os.path.basename(uri)
    if filename is not None:
        # log redundant renames for pkgcheck to flag
        if filename == default_filename:
            logger.info(f'redundant rename: {uri} -> {filename}')
    else:
        filename = default_filename

    if not filename:
        raise ValueError(f'missing filename: {uri!r}')

    preexisting = common_files.get(filename)

    if preexisting is None:
        if filename not in chksums and not ignore_missing_chksums:
            raise metadata_errors.MissingChksum(pkg, filename)
        uris = fetch.uri_list(filename)
    else:
        uris = preexisting.uri

    if filename != uri:
        if preexisting is None:
            if "primaryuri" not in pkg.restrict:
                if default_mirrors and "mirror" not in pkg.restrict:
                    uris.add_mirror(default_mirrors)

        if uri.startswith("mirror://"):
            # mirror:// is 9 chars.
            tier, remaining_uri = uri[9:].split("/", 1)
            mirror = mirrors.get(tier, fetch.unknown_mirror(tier))
            uris.add_mirror(mirror, sub_uri=remaining_uri)

        else:
            uris.add_uri(uri)
        if preexisting is None and "primaryuri" in pkg.restrict:
            if default_mirrors and "mirror" not in pkg.restrict:
                uris.add_mirror(default_mirrors)

    if preexisting is None:
        common_files[filename] = fetch.fetchable(filename, uris,
                                                 chksums.get(filename))
    return common_files[filename]
Example #4
0
def create_fetchable_from_uri(pkg,
                              chksums,
                              ignore_missing_chksums,
                              ignore_unknown_mirrors,
                              mirrors,
                              default_mirrors,
                              common_files,
                              uri,
                              filename=None):
    if filename is None:
        filename = os.path.basename(uri)

    preexisting = common_files.get(filename)

    if preexisting is None:
        if filename not in chksums and not ignore_missing_chksums:
            raise MissingChksum(filename)
        uris = uri_list(filename)
    else:
        uris = preexisting.uri

    if filename != uri:
        if preexisting is None:
            if "primaryuri" not in pkg.restrict:
                if default_mirrors and "mirror" not in pkg.restrict:
                    uris.add_mirror(default_mirrors)

        if uri.startswith("mirror://"):
            # mirror:// is 9 chars.

            tier, remaining_uri = uri[9:].split("/", 1)

            if tier not in mirrors:
                if not ignore_unknown_mirrors:
                    raise UnknownMirror(tier, remaining_uri)
            else:
                uris.add_mirror(mirrors[tier], remaining_uri)

        else:
            uris.add_uri(uri)
        if preexisting is None and "primaryuri" in pkg.restrict:
            if default_mirrors and "mirror" not in pkg.restrict:
                uris.add_mirror(default_mirrors)

    if preexisting is None:
        common_files[filename] = fetchable(filename, uris,
                                           chksums.get(filename))
    return common_files[filename]
Example #5
0
def create_fetchable_from_uri(
    pkg, chksums, ignore_missing_chksums, mirrors, default_mirrors, common_files, uri, filename=None
):

    if filename is None:
        filename = os.path.basename(uri)

    preexisting = common_files.get(filename)

    if preexisting is None:
        if filename not in chksums and not ignore_missing_chksums:
            raise MissingChksum(filename)
        uris = uri_list(filename)
    else:
        uris = preexisting.uri

    if filename != uri:
        if preexisting is None:
            if "primaryuri" not in pkg.restrict:
                if default_mirrors and "mirror" not in pkg.restrict:
                    uris.add_mirror(default_mirrors)

        if uri.startswith("mirror://"):
            # mirror:// is 9 chars.

            tier, remaining_uri = uri[9:].split("/", 1)

            if tier not in mirrors:
                raise UnknownMirror(tier, remaining_uri)

            uris.add_mirror(mirrors[tier], remaining_uri)

        else:
            uris.add_uri(uri)
        if preexisting is None and "primaryuri" in pkg.restrict:
            if default_mirrors and "mirror" not in pkg.restrict:
                uris.add_mirror(default_mirrors)

    if preexisting is None:
        common_files[filename] = fetchable(filename, uris, chksums.get(filename))
    return common_files[filename]
Example #6
0
 def setUp(self):
     self.uril = fetch.uri_list("cows")
Example #7
0
 def setUp(self):
     self.uril = fetch.uri_list("cows")