diff options
author | 2023-11-20 17:00:53 -0800 | |
---|---|---|
committer | 2023-11-24 17:17:21 +0200 | |
commit | e3276db7fd78c3d7514d97aae24eabbb924a1ff1 (patch) | |
tree | 8c7c3cb30cd0863b63f7f3333daa1ed985e827bc | |
parent | pquery: correct minor english typo in comments (diff) | |
download | pkgcore-e3276db7fd78c3d7514d97aae24eabbb924a1ff1.tar.gz pkgcore-e3276db7fd78c3d7514d97aae24eabbb924a1ff1.tar.bz2 pkgcore-e3276db7fd78c3d7514d97aae24eabbb924a1ff1.zip |
pquery: Fix --environment-re support .
This has been broken for a long while, thus I'm renaming
it to `--environment-re` (from `--environment`) in the
process.
Tests will follow in a later PR (pquery test infra needs some
work).
Signed-off-by: Brian Harring <ferringb@gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/415
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgcore/scripts/pquery.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py index 0a01702f..7211441f 100644 --- a/src/pkgcore/scripts/pquery.py +++ b/src/pkgcore/scripts/pquery.py @@ -16,6 +16,7 @@ running them on source repos makes no sense. import errno import os from functools import partial +import typing from snakeoil.cli import arghparse from snakeoil.formatters import decorate_forced_wrapping @@ -35,9 +36,17 @@ from ..util import parserestrict class DataSourceRestriction(values.base): """Turn a data_source into a line iterator and apply a restriction.""" - def __init__(self, childrestriction, **kwargs): + __slots__ = ("negate", "restriction") + + def __init__( + self, + childrestriction: typing.Union[values.base, values.AnyMatch], + negate=False, + **kwargs, + ): super().__init__(**kwargs) - self.restriction = childrestriction + object.__setattr__(self, "restriction", childrestriction) + object.__setattr__(self, "negate", negate) def __str__(self): return f"DataSourceRestriction: {self.restriction} negate={self.negate}" @@ -929,9 +938,11 @@ def parse_maintainer_email(value): @bind_add_query( - "--environment", action="append", help="regexp search in environment.bz2" + "--environment-re", + action="append", + help="regexp search of lines in environment.bz2", ) -def parse_envmatch(value): +def parse_environment_re(value): """Apply a regexp to the environment.""" return packages.PackageRestriction( "environment", DataSourceRestriction(values.AnyMatch(values.StrRegex(value))) |