[gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/ekeyword/, pym/gentoolkit/, ...

2023-03-19 Thread Sam James
commit: 5318fb2032cf24beafdda843af83c0a56d6c9dfe
Author: Sam James  gentoo  org>
AuthorDate: Mon Mar 20 04:40:25 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Mar 20 04:40:25 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=5318fb20

*/*: Reformat with newer Black

Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/dependencies.py   | 1 -
 pym/gentoolkit/ekeyword/ekeyword.py  | 1 -
 pym/gentoolkit/equery/uses.py| 1 -
 pym/gentoolkit/eshowkw/__init__.py   | 1 -
 pym/gentoolkit/revdep_rebuild/collect.py | 1 -
 pym/gentoolkit/textwrap_.py  | 1 -
 6 files changed, 6 deletions(-)

diff --git a/pym/gentoolkit/dependencies.py b/pym/gentoolkit/dependencies.py
index f94b82e..cff2080 100644
--- a/pym/gentoolkit/dependencies.py
+++ b/pym/gentoolkit/dependencies.py
@@ -268,7 +268,6 @@ class Dependencies(Query):
 and pkgdep.cpv not in seen
 and (depth < max_depth or max_depth == -1)
 ):
-
 seen.add(pkgdep.cpv)
 result.append(
 pkgdep.graph_reverse_depends(

diff --git a/pym/gentoolkit/ekeyword/ekeyword.py 
b/pym/gentoolkit/ekeyword/ekeyword.py
index 4d017d4..d031c2f 100755
--- a/pym/gentoolkit/ekeyword/ekeyword.py
+++ b/pym/gentoolkit/ekeyword/ekeyword.py
@@ -138,7 +138,6 @@ def diff_keywords(old_keywords, new_keywords, 
style="color-inline"):
 output = ""
 
 for tag, i0, i1, j0, j1 in s.get_opcodes():
-
 if tag == "equal":
 output += s.a[i0:i1]
 

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 89f011c..eeea356 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -337,7 +337,6 @@ def main(input_args):
 
 global_usedesc = get_global_useflags()
 for pkg in matches:
-
 output = get_output_descriptions(pkg, global_usedesc)
 if output:
 if CONFIG["verbose"]:

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index ee58e8c..4bef14e 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -25,7 +25,6 @@ topper = "versionlist"
 
 
 def process_display(package, keywords, dbapi):
-
 portdata = keywords_content(
 package, keywords.keywords, dbapi, ignore_slots, order, bold, topper
 )

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py 
b/pym/gentoolkit/revdep_rebuild/collect.py
index 0e5d274..897a12c 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -134,7 +134,6 @@ def collect_libraries_from_dir(dirs, mask, logger):
 or listing.endswith(".a")
 or ".so." in listing
 ):
-
 if os.path.islink(listing):
 found_symlinks.add(listing)
 else:

diff --git a/pym/gentoolkit/textwrap_.py b/pym/gentoolkit/textwrap_.py
index fd28c6a..dbacfec 100644
--- a/pym/gentoolkit/textwrap_.py
+++ b/pym/gentoolkit/textwrap_.py
@@ -47,7 +47,6 @@ class TextWrapper(textwrap.TextWrapper):
 ansi_re = re.compile(r"\x1b\[[0-9;]*m")
 
 while chunks:
-
 # Start the list of chunks that will make up the current line.
 # cur_len is just the length of all the chunks in cur_line.
 cur_line = []



[gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/

2022-07-09 Thread Brian Dolbec
commit: cc0b45fde4d333bd62da9988bc35418cd383c9ee
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Jul 10 03:41:54 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 03:44:38 2022 +
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  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



[gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/

2022-07-08 Thread Brian Dolbec
commit: c33468ba1d8ddd5a69516e8a39796db8de08ff63
Author: Oskari Pirhonen  gmail  com>
AuthorDate: Wed Jun  8 05:51:35 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sat Jul  9 02:40:24 2022 +
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  gmail.com>
Signed-off-by: Brian Dolbec  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(""))
 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:
+  

[gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/eclean/, pym/gentoolkit/test/eclean/, ...

2020-12-21 Thread Matt Turner
commit: 4c3ca2185c9bb71a028fb54953728c5a05807765
Author: Matt Turner  gentoo  org>
AuthorDate: Sun Dec 20 22:12:46 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sun Dec 20 22:12:46 2020 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=4c3ca218

Remove inherits from object

Signed-off-by: Matt Turner  gentoo.org>

 pym/gentoolkit/cpv.py | 2 +-
 pym/gentoolkit/eclean/clean.py| 2 +-
 pym/gentoolkit/eclean/output.py   | 2 +-
 pym/gentoolkit/eclean/pkgindex.py | 2 +-
 pym/gentoolkit/eclean/search.py   | 2 +-
 pym/gentoolkit/enalyze/lib.py | 4 ++--
 pym/gentoolkit/equery/belongs.py  | 2 +-
 pym/gentoolkit/equery/check.py| 2 +-
 pym/gentoolkit/equery/depends.py  | 2 +-
 pym/gentoolkit/formatters.py  | 2 +-
 pym/gentoolkit/helpers.py | 4 ++--
 pym/gentoolkit/keyword.py | 2 +-
 pym/gentoolkit/metadata.py| 8 
 pym/gentoolkit/module_base.py | 2 +-
 pym/gentoolkit/package.py | 2 +-
 pym/gentoolkit/revdep_rebuild/analyse.py  | 2 +-
 pym/gentoolkit/revdep_rebuild/assign.py   | 2 +-
 pym/gentoolkit/test/eclean/creator.py | 2 +-
 pym/gentoolkit/test/eclean/distsupport.py | 6 +++---
 pym/gentoolkit/test/eclean/test_clean.py  | 2 +-
 pym/gentoolkit/versionmatch.py| 2 +-
 21 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/pym/gentoolkit/cpv.py b/pym/gentoolkit/cpv.py
index 563dab8..5238e24 100644
--- a/pym/gentoolkit/cpv.py
+++ b/pym/gentoolkit/cpv.py
@@ -37,7 +37,7 @@ isvalid_rev_re = re.compile(r'(\d+|0\d+\.\d+)')
 # Classes
 # ===
 
-class CPV(object):
+class CPV:
"""Provides methods on a category/package-version string.
 
Will also correctly split just a package or package-version string.

diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py
index 2b750e3..3f6fe45 100644
--- a/pym/gentoolkit/eclean/clean.py
+++ b/pym/gentoolkit/eclean/clean.py
@@ -11,7 +11,7 @@ import gentoolkit.pprinter as pp
 from gentoolkit.eclean.pkgindex import PkgIndex
 
 
-class CleanUp(object):
+class CleanUp:
"""Performs all cleaning actions to distfiles or package directories.
 
@param controller: a progress output/user interaction controller 
function

diff --git a/pym/gentoolkit/eclean/output.py b/pym/gentoolkit/eclean/output.py
index 122d550..e2ed221 100644
--- a/pym/gentoolkit/eclean/output.py
+++ b/pym/gentoolkit/eclean/output.py
@@ -9,7 +9,7 @@ from portage.output import blue, yellow, teal, green, red
 from gentoolkit.pprinter import cpv, number
 
 
-class OutputControl(object):
+class OutputControl:
"""Outputs data according to predetermined options and handles any user
interaction.
 

diff --git a/pym/gentoolkit/eclean/pkgindex.py 
b/pym/gentoolkit/eclean/pkgindex.py
index 6cf9000..46c734d 100644
--- a/pym/gentoolkit/eclean/pkgindex.py
+++ b/pym/gentoolkit/eclean/pkgindex.py
@@ -13,7 +13,7 @@ from gentoolkit.eprefix import EPREFIX
 import portage
 
 
-class PkgIndex(object):
+class PkgIndex:
"""Handle the cleaning of the binpkg Package
Index file
 

diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py
index 992949c..8f6e52f 100644
--- a/pym/gentoolkit/eclean/search.py
+++ b/pym/gentoolkit/eclean/search.py
@@ -50,7 +50,7 @@ def get_distdir():
 distdir = get_distdir()
 
 
-class DistfilesSearch(object):
+class DistfilesSearch:
"""
 
@param output: verbose output method or (lambda x: None) to 
turn off

diff --git a/pym/gentoolkit/enalyze/lib.py b/pym/gentoolkit/enalyze/lib.py
index 8580bb7..50c7d11 100644
--- a/pym/gentoolkit/enalyze/lib.py
+++ b/pym/gentoolkit/enalyze/lib.py
@@ -17,7 +17,7 @@ from gentoolkit.flag import (reduce_flags, get_flags, 
get_all_cpv_use,
 import portage
 
 
-class FlagAnalyzer(object):
+class FlagAnalyzer:
"""Specialty functions for analysing an installed package's
USE flags.  Can be used for single or mulitple use without
needing to be reset unless the system USE flags are changed.
@@ -142,7 +142,7 @@ class FlagAnalyzer(object):
return _flags
 
 
-class KeywordAnalyser(object):
+class KeywordAnalyser:
"""Specialty functions for analysing the installed package db for
keyword useage and the packages that used them.
 

diff --git a/pym/gentoolkit/equery/belongs.py b/pym/gentoolkit/equery/belongs.py
index 8289366..1c9ab13 100644
--- a/pym/gentoolkit/equery/belongs.py
+++ b/pym/gentoolkit/equery/belongs.py
@@ -36,7 +36,7 @@ QUERY_OPTS = {
 # Classes
 # ===
 
-class BelongsPrinter(object):
+class BelongsPrinter:
"""Outputs a formatted list of packages that claim to own a files."""
 
def __init__(self, verbose=True, name_only=False):

diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py
index e965164..47eba98 1006

[gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/, pym/gentoolkit/test/eclean/, pym/gentoolkit/, ...

2020-01-26 Thread Michał Górny
commit: e7b20e89546857635e28cc05cc7cb4ab8cbd6ee7
Author: Michał Górny  gentoo  org>
AuthorDate: Sun Jan 26 15:06:24 2020 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jan 26 15:09:41 2020 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e7b20e89

Pass raw strings for regexp to fix DeprecationWarnings

Signed-off-by: Michał Górny  gentoo.org>

 pym/gentoolkit/cpv.py | 8 
 pym/gentoolkit/eclean/exclude.py  | 4 ++--
 pym/gentoolkit/equery/meta.py | 2 +-
 pym/gentoolkit/helpers.py | 4 ++--
 pym/gentoolkit/metadata.py| 2 +-
 pym/gentoolkit/revdep_rebuild/analyse.py  | 4 ++--
 pym/gentoolkit/revdep_rebuild/assign.py   | 2 +-
 pym/gentoolkit/revdep_rebuild/collect.py  | 2 +-
 pym/gentoolkit/revdep_rebuild/settings.py | 6 +++---
 pym/gentoolkit/test/eclean/distsupport.py | 2 +-
 pym/gentoolkit/test/eclean/test_search.py | 2 +-
 pym/gentoolkit/textwrap_.py   | 2 +-
 12 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/pym/gentoolkit/cpv.py b/pym/gentoolkit/cpv.py
index 6e272f1..169c833 100644
--- a/pym/gentoolkit/cpv.py
+++ b/pym/gentoolkit/cpv.py
@@ -28,10 +28,10 @@ from gentoolkit import errors
 # Globals
 # ===
 
-isvalid_version_re = re.compile("^(?:cvs\\.)?(?:\\d+)(?:\\.\\d+)*[a-z]?"
-   "(?:_(p(?:re)?|beta|alpha|rc)\\d*)*$")
-isvalid_cat_re = re.compile("^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$")
-_pkg_re = re.compile("^[a-zA-Z0-9+._]+$")
+isvalid_version_re = re.compile(r"^(?:cvs\\.)?(?:\\d+)(?:\\.\\d+)*[a-z]?"
+   r"(?:_(p(?:re)?|beta|alpha|rc)\\d*)*$")
+isvalid_cat_re = re.compile(r"^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$")
+_pkg_re = re.compile(r"^[a-zA-Z0-9+._]+$")
 # Prefix specific revision is of the form -r0+.+
 isvalid_rev_re = re.compile(r'(\d+|0\d+\.\d+)')
 

diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py
index 0d2d0c4..c734493 100644
--- a/pym/gentoolkit/eclean/exclude.py
+++ b/pym/gentoolkit/eclean/exclude.py
@@ -90,8 +90,8 @@ def parseExcludeFile(filepath, output):
filepath)
filecontents = file_.readlines()
file_.close()
-   cat_re = re.compile('^(?P[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$')
-   cp_re = re.compile('^(?P[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$')
+   cat_re = re.compile(r'^(?P[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$')
+   cp_re = re.compile(r'^(?P[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$')
# used to output the line number for exception error reporting
linenum = 0
for line in filecontents:

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index d08ab23..2e8f91e 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -428,7 +428,7 @@ def format_line(line, first="", subsequent="", 
force_quiet=False):
twrap = TextWrapper(width=CONFIG['termWidth'], 
expand_tabs=False,
initial_indent=first, subsequent_indent=subsequent)
line = " ".join(line)
-   line = re.sub("\s+", " ", line)
+   line = re.sub(r"\s+", " ", line)
line = line.lstrip()
result = twrap.fill(line)
else:

diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index 40235d5..a551550 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -257,7 +257,7 @@ class FileOwner(object):
raise errors.GentoolkitInvalidRegex(err)
 
use_match = False
-   if ((self.is_regex or query_re_string.startswith('^\/'))
+   if ((self.is_regex or query_re_string.startswith(r'^\/'))
and '|' not in query_re_string ):
# If we were passed a regex or a single path starting 
with root,
# we can use re.match, else use re.search.
@@ -350,7 +350,7 @@ class FileOwner(object):
else:
result = []
# Trim trailing and multiple slashes from queries
-   slashes = re.compile('/+')
+   slashes = re.compile(r'/+')
queries = self.expand_abspaths(queries)
queries = self.extend_realpaths(queries)
for query in queries:

diff --git a/pym/gentoolkit/metadata.py b/pym/gentoolkit/metadata.py
index 7828bae..22c249e 100644
--- a/pym/gentoolkit/metadata.py
+++ b/pym/gentoolkit/metadata.py
@@ -105,7 +105,7 @@ class _Useflag(object):
_desc += child.text if child.text else ''
_desc += child.tail if child.tail else ''
# This takes care of tabs and newlines left from the file
-   self.description = re.sub('\s+', ' ', _desc)
+   self.description = re.sub(r'\s+', ' ', _desc)
 
def __repr__(self):
return "<%s %r>" % (se