* [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/
@ 2022-07-09 2:41 Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2022-07-09 2:41 UTC (permalink / raw
To: gentoo-commits
commit: c33468ba1d8ddd5a69516e8a39796db8de08ff63
Author: Oskari Pirhonen <xxc3ncoredxx <AT> gmail <DOT> com>
AuthorDate: Wed Jun 8 05:51:35 2022 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 9 02:40:24 2022 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c33468ba
Add -f/--forced-masked to equery uses
Option to include forced and masked USE flags in `equery uses` output.
- Marked with F / M in verbose/normal output
- Marked with (+flag) / (-flag) in non-verbose/piped output
Signed-off-by: Oskari Pirhonen <xxc3ncoredxx <AT> gmail.com>
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/gentoolkit/equery/uses.py | 62 ++++++++++++++++++++++++++++++++++---------
pym/gentoolkit/flag.py | 36 +++++++++++++++++++------
2 files changed, 77 insertions(+), 21 deletions(-)
diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 7c90b90..7af7f43 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -31,7 +31,11 @@ from gentoolkit.flag import get_flags, reduce_flags
# Globals
# =======
-QUERY_OPTS = {"all_versions": False, "ignore_l10n": False}
+QUERY_OPTS = {
+ "all_versions": False,
+ "forced_masked": False,
+ "ignore_l10n": False,
+}
# =========
# Functions
@@ -56,6 +60,7 @@ def print_help(with_description=True):
(
(" -h, --help", "display this help message"),
(" -a, --all", "include all package versions"),
+ (" -f, --forced-masked", "include forced/masked USE flags"),
(" -i, --ignore-l10n", "don't show l10n USE flags"),
)
)
@@ -67,8 +72,14 @@ def display_useflags(output):
@type output: list
@param output: [(inuse, inused, flag, desc, restrict), ...]
- inuse (int) = 0 or 1; if 1, flag is set in make.conf
- inused (int) = 0 or 1; if 1, package is installed with flag enabled
+ inuse (int) = 0, 1, 2, 3;
+ if 1, flag is set in make.conf;
+ if 2, flag is masked;
+ if 3, flag is forced
+ inused (int) = 0, 1, 2, 3;
+ if 1, package is installed with flag enabled;
+ if 2, flag is masked;
+ if 3, flag is forced
flag (str) = the name of the USE flag
desc (str) = the flag's description
restrict (str) = corresponds to the text of restrict in metadata
@@ -80,7 +91,8 @@ def display_useflags(output):
twrap.width = CONFIG["termWidth"]
twrap.subsequent_indent = " " * (maxflag_len + 8)
- markers = ("-", "+")
+ markers = ("-", "+", "M", "F")
+ # Colors for masked/forced = unset/set (mod 2)
color = (partial(pp.useflag, enabled=False), partial(pp.useflag, enabled=True))
for in_makeconf, in_installed, flag, desc, restrict in output:
if CONFIG["verbose"]:
@@ -92,7 +104,7 @@ def display_useflags(output):
else:
flag_name += " %s %s" % (markers[in_makeconf], markers[in_installed])
- flag_name += " " + color[in_makeconf](flag.ljust(maxflag_len))
+ flag_name += " " + color[in_makeconf % 2](flag.ljust(maxflag_len))
flag_name += " : "
# Strip initial whitespace at the start of the description
@@ -119,7 +131,11 @@ def display_useflags(output):
twrap.initial_indent = flag_name
print(twrap.fill("<unknown>"))
else:
- pp.uprint(markers[in_makeconf] + flag)
+ # Match emerge -v output for forced/masked flags
+ if in_makeconf > 1:
+ pp.uprint("(" + markers[in_makeconf % 2] + flag + ")")
+ else:
+ pp.uprint(markers[in_makeconf] + flag)
def get_global_useflags():
@@ -184,7 +200,16 @@ def get_output_descriptions(pkg, global_usedesc):
else:
local_usedesc = pkg.metadata.use()
- iuse, final_use = get_flags(pkg.cpv, final_setting=True)
+ useforced = []
+ usemasked = []
+ if QUERY_OPTS["forced_masked"]:
+ iuse, final_use, useforced, usemasked = get_flags(
+ pkg.cpv, final_setting=True, include_forced_masked=True
+ )
+ else:
+ iuse, final_use = get_flags(
+ pkg.cpv, final_setting=True, include_forced_masked=False
+ )
usevar = reduce_flags(iuse)
usevar.sort()
@@ -202,8 +227,8 @@ def get_output_descriptions(pkg, global_usedesc):
# store (inuse, inused, flag, desc, restrict)
output = []
for flag in usevar:
- inuse = False
- inused = False
+ inuse = 0
+ inused = 0
local_use = None
for use in local_usedesc:
@@ -226,9 +251,18 @@ def get_output_descriptions(pkg, global_usedesc):
restrict = ""
if flag in final_use:
- inuse = True
+ inuse = 1
+ if flag in useforced:
+ inuse = 3
+ elif flag in usemasked:
+ inuse = 2
+
if flag in used_flags:
- inused = True
+ inused = 1
+ if flag in useforced:
+ inused = 3
+ elif flag in usemasked:
+ inused = 2
output.append((inuse, inused, flag, desc, restrict))
@@ -245,6 +279,8 @@ def parse_module_options(module_opts):
sys.exit(0)
elif opt in ("-a", "--all"):
QUERY_OPTS["all_versions"] = True
+ elif opt in ("-f", "--forced-masked"):
+ QUERY_OPTS["forced_masked"] = True
elif opt in ("-i", "--ignore-l10n"):
QUERY_OPTS["ignore_l10n"] = True
@@ -263,8 +299,8 @@ def print_legend():
def main(input_args):
"""Parse input and run the program"""
- short_opts = "hai"
- long_opts = ("help", "all", "ignore-l10n")
+ short_opts = "hafi"
+ long_opts = ("help", "all", "forced-masked", "ignore-l10n")
try:
module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
diff --git a/pym/gentoolkit/flag.py b/pym/gentoolkit/flag.py
index 20ba855..478eb6d 100644
--- a/pym/gentoolkit/flag.py
+++ b/pym/gentoolkit/flag.py
@@ -163,7 +163,7 @@ def get_all_cpv_use(cpv):
return use, use_expand_hidden, usemask, useforce
-def get_flags(cpv, final_setting=False):
+def get_flags(cpv, final_setting=False, include_forced_masked=False):
"""Retrieves all information needed to filter out hidded, masked, etc.
USE flags for a given package.
@@ -172,12 +172,32 @@ def get_flags(cpv, final_setting=False):
@type final_setting: boolean
@param final_setting: used to also determine the final
enviroment USE flag settings and return them as well.
- @rtype: list or list, list
- @return IUSE or IUSE, final_flags
+ @type include_forced_masked: boolean
+ @param include_forced_masked: used to toggle the inclusion of forced and
+ masked USE flags in the returned result.
+ @rtype: list
+ or list, list
+ or list, list, list
+ or list, list, list, list
+ @return IUSE
+ or IUSE, final_flags
+ or IUSE, useforced, usemasked
+ or IUSE, final_flags, useforced, usemasked
"""
final_use, use_expand_hidden, usemasked, useforced = get_all_cpv_use(cpv)
- iuse_flags = filter_flags(get_iuse(cpv), use_expand_hidden, usemasked, useforced)
- if final_setting:
- final_flags = filter_flags(final_use, use_expand_hidden, usemasked, useforced)
- return iuse_flags, final_flags
- return iuse_flags
+ if include_forced_masked:
+ iuse_flags = filter_flags(get_iuse(cpv), use_expand_hidden, [], [])
+ if final_setting:
+ final_flags = filter_flags(final_use, use_expand_hidden, [], [])
+ return iuse_flags, final_flags, useforced, usemasked
+ return iuse_flags, useforced, usemasked
+ else:
+ iuse_flags = filter_flags(
+ get_iuse(cpv), use_expand_hidden, usemasked, useforced
+ )
+ if final_setting:
+ final_flags = filter_flags(
+ final_use, use_expand_hidden, usemasked, useforced
+ )
+ return iuse_flags, final_flags
+ return iuse_flags
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/
@ 2022-07-10 3:47 Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2022-07-10 3:47 UTC (permalink / raw
To: gentoo-commits
commit: cc0b45fde4d333bd62da9988bc35418cd383c9ee
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 03:41:54 2022 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 03:44:38 2022 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=cc0b45fd
equery meta: Fix missing description when not in metadata.xml
Add description property to Package class.
If no description in metadata.xml, get the description from the ebuild.
Bug: https://bugs.gentoo.org/447538
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/gentoolkit/equery/meta.py | 2 ++
pym/gentoolkit/package.py | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index 2e8dc36..124f59b 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -331,6 +331,8 @@ def call_format_functions(best_match, matches):
if QUERY_OPTS["description"]:
desc = best_match.metadata.descriptions()
+ if not desc:
+ desc = best_match.description
print_sequence(format_list(desc))
if QUERY_OPTS["useflags"]:
diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py
index 92bc3a3..1110bf5 100644
--- a/pym/gentoolkit/package.py
+++ b/pym/gentoolkit/package.py
@@ -437,6 +437,15 @@ class Package(CPV):
)
return self.cpv not in unmasked
+ @property
+ def description(self):
+ """Returns the DESCRIPTION from the ebuild
+
+ @rtype: list
+ """
+
+ return portage.db[portage.root]["porttree"].dbapi.aux_get(self.cpv, ["DESCRIPTION"])
+
class PackageFormatter:
"""When applied to a L{gentoolkit.package.Package} object, determine the
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-10 3:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-09 2:41 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2022-07-10 3:47 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox