Exemplo n.º 1
0
 def test_eq_ne(self):
     o1 = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf":1})
     self.assertEqual(o1, o1)
     o2 = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf":1})
     self.assertEqual(o1, o2)
     self.assertNotEqual(o1,
         fetch.fetchable("dar1", uri=["asdf"], chksums={"asdf":1}))
     self.assertNotEqual(o1,
         fetch.fetchable("dar", uri=["asdf1"], chksums={"asdf":1}))
     self.assertNotEqual(o1,
         fetch.fetchable("dar", uri=["asdf1"], chksums={"asdf":1, "foon":1}))
Exemplo n.º 2
0
 def test_eq_ne(self):
     o1 = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf":1})
     self.assertEqual(o1, o1)
     o2 = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf":1})
     self.assertEqual(o1, o2)
     self.assertNotEqual(o1,
         fetch.fetchable("dar1", uri=["asdf"], chksums={"asdf":1}))
     self.assertNotEqual(o1,
         fetch.fetchable("dar", uri=["asdf1"], chksums={"asdf":1}))
     self.assertNotEqual(o1,
         fetch.fetchable("dar", uri=["asdf1"], chksums={"asdf":1, "foon":1}))
Exemplo n.º 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]
Exemplo n.º 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]
Exemplo n.º 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]
Exemplo n.º 6
0
 def setUp(self):
     TempDirMixin.setUp(self)
     self.fp = os.path.join(self.dir, "test")
     self.obj = fetchable(self.fp, chksums=chksums)
     self.fetcher = base.fetcher()
Exemplo n.º 7
0
 def _setup(self, tmpdir):
     self.fp = os.path.join(str(tmpdir), "test")
     self.obj = fetchable(self.fp, chksums=chksums)
     self.fetcher = base.fetcher()
Exemplo n.º 8
0
 def test_init(self):
     o = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf":1})
     self.assertEqual(o.filename, "dar")
     self.assertUri(o.uri, ["asdf"])
     self.assertEqual(o.chksums, {"asdf":1})
Exemplo n.º 9
0
 def setUp(self):
     TempDirMixin.setUp(self)
     self.fp = os.path.join(self.dir, "test")
     self.obj = fetchable(self.fp, chksums=chksums)
     self.fetcher = base.fetcher()
Exemplo n.º 10
0
 def _setup(self, tmpdir):
     self.fp = os.path.join(str(tmpdir), "test")
     self.obj = fetchable(self.fp, chksums=chksums)
     self.fetcher = base.fetcher()
Exemplo n.º 11
0
 def test_init(self):
     o = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf":1})
     self.assertEqual(o.filename, "dar")
     self.assertUri(o.uri, ["asdf"])
     self.assertEqual(o.chksums, {"asdf":1})