How to use the pkgcore.restrictions.values.StrExactMatch function in pkgcore

To help you get started, we’ve selected a few pkgcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pkgcore / pkgcore / tests / module / repository / test_prototype.py View on Github external
sorted(VersionedCPV(x) for x in (
                "dev-util/diffball-0.7", "dev-util/diffball-1.0",
                "dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))

        self.assertEqual(
            sorted(self.repo.itermatch(
                packages.OrRestriction(packages.AlwaysTrue, rp2))),
            sorted(VersionedCPV(x) for x in (
                "dev-util/diffball-0.7", "dev-util/diffball-1.0",
                "dev-util/bsdiff-0.4.1", "dev-util/bsdiff-0.4.2",
                "dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))

        self.assertEqual(
            sorted(self.repo.itermatch(
                packages.PackageRestriction(
                    'category', values.StrExactMatch('dev-util', negate=True)))),
            sorted(VersionedCPV(x) for x in ("dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))

        obj = malleable_obj(livefs=False)
        pkg_cls = post_curry(MutatedPkg, {'repo': obj})
        self.assertEqual(
            sorted(self.repo.itermatch(
                boolean.AndRestriction(
                    boolean.OrRestriction(
                        packages.PackageRestriction(
                            "repo.livefs", values.EqualityMatch(False)),
                        packages.PackageRestriction(
                            "category", values.StrExactMatch("virtual"))),
                    atom("dev-lib/fake")),
                pkg_cls=pkg_cls)),
            sorted(VersionedCPV(x) for x in (
                "dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))
github pkgcore / pkgcore / tests / module / repository / test_prototype.py View on Github external
self.assertEqual(
            sorted(self.repo.itermatch(
                packages.PackageRestriction(
                    'category', values.StrExactMatch('dev-util', negate=True)))),
            sorted(VersionedCPV(x) for x in ("dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))

        obj = malleable_obj(livefs=False)
        pkg_cls = post_curry(MutatedPkg, {'repo': obj})
        self.assertEqual(
            sorted(self.repo.itermatch(
                boolean.AndRestriction(
                    boolean.OrRestriction(
                        packages.PackageRestriction(
                            "repo.livefs", values.EqualityMatch(False)),
                        packages.PackageRestriction(
                            "category", values.StrExactMatch("virtual"))),
                    atom("dev-lib/fake")),
                pkg_cls=pkg_cls)),
            sorted(VersionedCPV(x) for x in (
                "dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))

        self.assertEqual(
            sorted(self.repo.itermatch(
                packages.PackageRestriction(
                    'category', values.StrExactMatch('dev-lib', negate=True),
                    negate=True))),
            sorted(VersionedCPV(x) for x in (
                "dev-lib/fake-1.0", "dev-lib/fake-1.0-r1")))

        self.assertEqual(
            sorted(self.repo.itermatch(
                packages.PackageRestriction(
github pkgcore / pkgcore / pkgcore / vdb / virtuals.py View on Github external
update = False
    cache = _read_mtime_cache(pjoin(cache_basedir, 'virtuals.cache'))

    existing = _get_mtimes(repo.location)
    for cat, mtime in existing.iteritems():
        d = cache.pop(cat, None)
        if d is not None and long(d[0]) == long(mtime):
            d = _convert_cached_virtuals(d)
            if d is not None:
                _merge_virtuals(virtuals, d)
                continue

        update = True
        _collect_virtuals(virtuals, repo.itermatch(
            packages.PackageRestriction("category",
                values.StrExactMatch(cat))))

    if update or cache:
        _write_mtime_cache(existing, virtuals,
            pjoin(cache_basedir, 'virtuals.cache'))

    defaults = _collect_default_providers(virtuals)
#    _finalize_virtuals(virtuals)
    return defaults, virtuals
github pkgcore / pkgcore / src / pkgcore / util / parserestrict.py View on Github external
def convert_glob(token):
    if token in ('*', ''):
        return None
    elif '*' not in token:
        return values.StrExactMatch(token)
    elif not valid_globbing(token):
        raise ParseError(
            "globs must be composed of [\\w-.+], with optional "
            f"'*'- {token!r} is disallowed however")
    pattern = re.escape(token).replace('\\*', '.*')
    pattern = f"^{pattern}$"
    return values.StrRegex(pattern, match=True)
github pkgcore / pkgcore / pkgcore / util / parserestrict.py View on Github external
def convert_glob(token):
    if token in ('*', ''):
        return None
    elif '*' not in token:
        return values.StrExactMatch(token)
    elif not valid_globbing(token):
        raise ParseError(
            "globs must be composed of [\w-.+], with optional "
            "'*'- '%s' is disallowed however" % token)
    pattern = "^%s$" % (re.escape(token).replace("\*", ".*"),)
    return values.StrRegex(pattern, match=True)