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

2024-03-07 Thread Sam James
commit: b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b
Author: John Turner  gmail  com>
AuthorDate: Fri Feb 23 01:38:29 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Mar  7 18:49:06 2024 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b2dbcb18

equery/depends: print output in module rather than with a callback

The depends module can now iterate over the results of the
graph_reverse_depends function and print the items as they are
yielded.

Before, it passed in a callback printer function, and expected the
Dependencies class to call it correctly.

This setup is nicer because it does not tie together this module and
the Dependencies class, and the old setup most likely existed due to
performance and interactivity concerns which are now fixed by turning
graph_reverse_depends into an iterator.

Signed-off-by: John Turner  gmail.com>
Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/equery/depends.py | 29 ++---
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py
index 8ec5f75..f92b7b9 100644
--- a/pym/gentoolkit/equery/depends.py
+++ b/pym/gentoolkit/equery/depends.py
@@ -17,7 +17,6 @@ import gentoolkit.pprinter as pp
 from gentoolkit.dependencies import Dependencies
 from gentoolkit.equery import format_options, mod_usage, CONFIG
 from gentoolkit.helpers import get_cpvs, get_installed_cpvs
-from gentoolkit.cpv import CPV
 from gentoolkit.package import PackageFormatter, Package
 
 # ===
@@ -27,7 +26,7 @@ from gentoolkit.package import PackageFormatter, Package
 QUERY_OPTS = {
 "include_masked": False,
 "only_direct": True,
-"max_depth": -1,
+"max_depth": None,
 "package_format": None,
 }
 
@@ -94,9 +93,9 @@ class DependPrinter:
 if dep_is_displayed and not self.verbose:
 return
 
-depth = getattr(dep, "depth", 0)
+depth = dep.depth
 indent = " " * depth
-mdep = dep.matching_dep
+mdep = dep.depatom
 use_conditional = ""
 
 if QUERY_OPTS["package_format"] != None:
@@ -226,17 +225,25 @@ def main(input_args):
 
 if CONFIG["verbose"]:
 print(" * These packages depend on %s:" % pp.emph(pkg.cpv))
-if pkg.graph_reverse_depends(
-pkgset=sorted(pkggetter(), key=CPV),
-max_depth=QUERY_OPTS["max_depth"],
+
+first_run = False
+
+last_seen = None
+for pkgdep in pkg.graph_reverse_depends(
+pkgset=sorted(pkggetter()),
 only_direct=QUERY_OPTS["only_direct"],
-printer_fn=dep_print,
+max_depth=QUERY_OPTS["max_depth"],
 ):
+if last_seen is None or last_seen != pkgdep:
+seen = False
+else:
+seen = True
+printer(pkgdep, dep_is_displayed=seen)
+last_seen = pkgdep
+if last_seen is not None:
 got_match = True
 
-first_run = False
-
-if not got_match:
+if got_match is None:
 sys.exit(1)
 
 



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

2024-03-07 Thread Sam James
commit: b9294a02b804f0286f22625d563a1f92a1bb24b3
Author: John Turner  gmail  com>
AuthorDate: Tue Feb 27 20:20:11 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Mar  7 18:49:07 2024 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b9294a02

depends.py: rename DependPrinter to Printer

The DependPrinter class name and documentation indicated that it was
meant to be part of the gentoolkit.dependencies API, to print
Dependencies objects. This Printer class is used exclusively for
printering equery depends output and is not a public API outside of
the depends.py module

Signed-off-by: John Turner  gmail.com>
Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/equery/depends.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py
index f92b7b9..39e0b25 100644
--- a/pym/gentoolkit/equery/depends.py
+++ b/pym/gentoolkit/equery/depends.py
@@ -35,8 +35,8 @@ QUERY_OPTS = {
 # ===
 
 
-class DependPrinter:
-"""Output L{gentoolkit.dependencies.Dependencies} objects."""
+class Printer:
+"""Output L{gentoolkit.dependencies.Dependencies} objects for equery 
depends."""
 
 def __init__(self, verbose=True):
 self.verbose = verbose
@@ -83,7 +83,7 @@ class DependPrinter:
 )
 
 def format_depend(self, dep, dep_is_displayed):
-"""Format a dependency for printing.
+"""Format a dependency for printing for equery depends.
 
 @type dep: L{gentoolkit.dependencies.Dependencies}
 @param dep: the dependency to display
@@ -209,7 +209,7 @@ def main(input_args):
 # Output
 #
 
-dep_print = DependPrinter(verbose=CONFIG["verbose"])
+printer = Printer(verbose=CONFIG["verbose"])
 
 first_run = True
 got_match = False



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

2023-09-19 Thread Sam James
commit: 5146d35eb97e2c1a8f7691e59c755ed14e858dd4
Author: Siddhanth Rathod  gmail  com>
AuthorDate: Tue Sep 19 18:31:49 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Sep 19 19:13:02 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=5146d35e

equery meta: map the remote-id to the respective url

Bug: https://bugs.gentoo.org/877519
Signed-off-by: Siddhanth Rathod  gmail.com>
Closes: https://github.com/gentoo/gentoolkit/pull/32
Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/equery/meta.py | 51 ++-
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index 02b6f67..de5631b 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -10,19 +10,19 @@ __docformat__ = "epytext"
 # Imports
 # ===
 
-import re
 import os
+import re
 import sys
 import warnings
-from getopt import gnu_getopt, GetoptError
+from getopt import GetoptError, gnu_getopt
 
 import gentoolkit.pprinter as pp
 from gentoolkit import errors
+from gentoolkit.equery import CONFIG, format_options, mod_usage
+from gentoolkit.helpers import print_file, print_sequence
 from gentoolkit.keyword import Keyword
-from gentoolkit.equery import format_options, mod_usage, CONFIG
-from gentoolkit.helpers import print_sequence, print_file
-from gentoolkit.textwrap_ import TextWrapper
 from gentoolkit.query import Query
+from gentoolkit.textwrap_ import TextWrapper
 
 # ===
 # Globals
@@ -189,11 +189,42 @@ def format_upstream(upstream):
 
 def _format_upstream_ids(ids):
 result = []
-for id_ in ids:
-site = id_[0]
-proj_id = id_[1]
-idstr = f"{site} ID: {proj_id}"
-result.append(idstr)
+remote_ids = {
+"github": "https://github.com/remote-id;,
+"gentoo": "https://gitweb.gentoo.org/remote-id.git/;,
+"bitbucket": "https://bitbucket.org/remote-id;,
+"codeberg": "https://codeberg.org/remote-id;,
+"cpan": "https://metacpan.org/dist/remote-id;,
+"cpan-module": "https://metacpan.org/pod/remote-id;,
+"cpe": "remote-id",
+"cran": "https://cran.r-project.org/web/packages/remote-id/;,
+"ctan": "https://ctan.org/pkg/remote-id;,
+"freedesktop-gitlab": 
"https://gitlab.freedesktop.org/remote-id.git/;,
+"gitlab": "https://gitlab.com/remote-id;,
+"gnome-gitlab": "https://gitlab.gnome.org/remote-id.git/;,
+"google-code": "https://code.google.com/archive/p/remote-id/;,
+"hackage": "https://hackage.haskell.org/package/remote-id;,
+"heptapod": "https://foss.heptapod.net/remote-id;,
+"kde-invent": "https://invent.kde.org/remote-id;,
+"launchpad": "https://launchpad.net/remote-id;,
+"osdn": "https://osdn.net/projects/remote-id/;,
+"pear": "https://pear.php.net/package/remote-id;,
+"pecl": "https://pecl.php.net/package/remote-id;,
+"pypi": "https://pypi.org/project/remote-id/;,
+"rubygems": "https://rubygems.org/gems/remote-id/;,
+"savannah": "https://savannah.gnu.org/projects/remote-id;,
+"savannah-nongnu": 
"https://savannah.nongnu.org/projects/remote-id;,
+"sourceforge": "https://sourceforge.net/projects/remote-id/;,
+"sourcehut": "https://sr.ht/remote-id/;,
+"vim": 
"https://www.vim.org/scripts/script.php?script_id=remote-id;,
+}
+for id in ids:
+proj_id = id[1]
+try:
+site = remote_ids[proj_id].replace("remote-id", id[0])
+except KeyError:
+site = id[0]
+result.append(f"{site} ({proj_id})")
 return result
 
 result = []



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

2023-08-04 Thread Sam James
commit: 9fbd05c05f86bb9c67d229ea64fe72c5ea08cf62
Author: Sam James  gentoo  org>
AuthorDate: Sat Aug  5 05:38:40 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Aug  5 05:38:45 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=9fbd05c0

equery: reformat with black

Fixes: 637bfbfb27d2104a81d80e5c67a7878d2e874966
Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/equery/list_.py | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/equery/list_.py b/pym/gentoolkit/equery/list_.py
index 9b38c3e..237e7fe 100644
--- a/pym/gentoolkit/equery/list_.py
+++ b/pym/gentoolkit/equery/list_.py
@@ -233,10 +233,16 @@ def main(input_args):
 )
 
 if QUERY_OPTS["in_porttree"] and not QUERY_OPTS["in_overlay"]:
-if not ("P" in pkgstr.location or (QUERY_OPTS['in_installed'] 
and 'I' in pkgstr.location)):
+if not (
+"P" in pkgstr.location
+or (QUERY_OPTS["in_installed"] and "I" in pkgstr.location)
+):
 continue
 if QUERY_OPTS["in_overlay"] and not QUERY_OPTS["in_porttree"]:
-if not ("O" in pkgstr.location or (QUERY_OPTS['in_installed'] 
and 'I' in pkgstr.location)):
+if not (
+"O" in pkgstr.location
+or (QUERY_OPTS["in_installed"] and "I" in pkgstr.location)
+):
 continue
 pp.uprint(pkgstr)
 



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

2023-07-18 Thread Sam James
commit: 637bfbfb27d2104a81d80e5c67a7878d2e874966
Author: Rafał Mużyło  o2  pl>
AuthorDate: Tue Jul 18 22:28:44 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 18 22:28:44 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=637bfbfb

equery: list: correctly handle installed packages no longer in tree

Closes: https://bugs.gentoo.org/369581
Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/equery/list_.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/equery/list_.py b/pym/gentoolkit/equery/list_.py
index 1e03d91..9b38c3e 100644
--- a/pym/gentoolkit/equery/list_.py
+++ b/pym/gentoolkit/equery/list_.py
@@ -233,10 +233,10 @@ def main(input_args):
 )
 
 if QUERY_OPTS["in_porttree"] and not QUERY_OPTS["in_overlay"]:
-if not "P" in pkgstr.location:
+if not ("P" in pkgstr.location or (QUERY_OPTS['in_installed'] 
and 'I' in pkgstr.location)):
 continue
 if QUERY_OPTS["in_overlay"] and not QUERY_OPTS["in_porttree"]:
-if not "O" in pkgstr.location:
+if not ("O" in pkgstr.location or (QUERY_OPTS['in_installed'] 
and 'I' in pkgstr.location)):
 continue
 pp.uprint(pkgstr)
 



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

2023-07-18 Thread Sam James
commit: 9eeff3399b23df1e4eed6f782e77c28b30347c9a
Author: Sam James  gentoo  org>
AuthorDate: Tue Jul 18 22:26:33 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 18 22:26:50 2023 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=9eeff339

equery: depgraph: Fix --linear shortopt (-l)

Closes: https://bugs.gentoo.org/709816
Signed-off-by: Sam James  gentoo.org>

 pym/gentoolkit/equery/depgraph.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/equery/depgraph.py 
b/pym/gentoolkit/equery/depgraph.py
index 9003a47..d9e3901 100644
--- a/pym/gentoolkit/equery/depgraph.py
+++ b/pym/gentoolkit/equery/depgraph.py
@@ -197,7 +197,7 @@ def main(input_args):
 """Parse input and run the program"""
 
 short_opts = "hAMUl"
-long_opts = ("help", "no-atom", "no-useflags", "no-mask", "depth=")
+long_opts = ("help", "no-atom", "no-useflags", "no-mask", "depth=", 
"linear")
 
 try:
 module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)



[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/

2022-07-28 Thread Brian Dolbec
commit: 91721fcdb85ff67f7607dad60e82f11c1bf701fd
Author: Brian Dolbec  gentoo  org>
AuthorDate: Tue Jul 12 01:37:37 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Tue Jul 12 01:37:37 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=91721fcd

equery meta: Put maintainer description on the same line

Bug: https://bugs.gentoo.org/576224

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/meta.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index 124f59b..22e9ad8 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -167,7 +167,7 @@ def format_maintainers(maints):
 if CONFIG["verbose"]:
 maintstr += " (%s)" % (maint.name,) if maint.name else ""
 maintstr += " - %s" % (maint.restrict,) if maint.restrict else ""
-maintstr += "\n%s" % (maint.description,) if maint.description 
else ""
+maintstr += " - %s" % (maint.description,) if maint.description 
else ""
 result.append(maintstr)
 
 return result



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

2022-07-28 Thread Brian Dolbec
commit: 9a402fba0d63240685a2326926060c3c8c523101
Author: Brian Dolbec  gentoo  org>
AuthorDate: Thu Jul 28 15:22:55 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Thu Jul 28 15:22:55 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=9a402fba

equery: Set nocolor for piping to after options are parsed

Fixes commit 84ffe42e5 which set nocolor before options were parsed.

Bug: https://bugs.gentoo.org/861116

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/__init__.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/equery/__init__.py 
b/pym/gentoolkit/equery/__init__.py
index 56b2caa..ae760c1 100644
--- a/pym/gentoolkit/equery/__init__.py
+++ b/pym/gentoolkit/equery/__init__.py
@@ -228,8 +228,6 @@ def initialize_configuration():
 # set extra wide, should disable wrapping unless
 # there is some extra long text
 CONFIG["termWidth"] = 600
-# turn off color
-pp.output.nocolor()
 
 CONFIG["debug"] = bool(os.getenv("DEBUG", False))
 
@@ -338,6 +336,10 @@ def main(argv):
 else:
 CONFIG["verbose"] = True
 
+if CONFIG["piping"]:
+# turn off color
+pp.output.nocolor()
+
 try:
 module_name, module_args = split_arguments(args)
 except IndexError:



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

2022-07-10 Thread Brian Dolbec
commit: 68159035c6479e313c33dd31d19d42d3178f1235
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Jul 10 18:25:18 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 18:25:18 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=68159035

equery check.py: Fix flake 8 qa for unused variable

flake8 did not correctly detect the way the variable is used.
Add an assert to eliminate the false detection.

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/check.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py
index 7e580b1..2ef881c 100644
--- a/pym/gentoolkit/equery/check.py
+++ b/pym/gentoolkit/equery/check.py
@@ -144,6 +144,7 @@ class VerifyContents:
 obj_errs.append(err % locals())
 return obj_errs
 except Exception as ex:
+assert ex  # to silence unused variable ex
 err = "Problem checking %(cfile)s: %(ex)s"
 obj_errs.append(err % locals())
 return obj_errs



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

2022-07-10 Thread Brian Dolbec
commit: d755f0f7c8e6b21f926837d46440768d58281b04
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Jul 10 17:58:42 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 17:58:42 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=d755f0f7

depends.py: Fix 3e35553df46 missing Package import

Remove unused FORMAT_TMPL_VARS import

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/depends.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py
index fe56148..8ec5f75 100644
--- a/pym/gentoolkit/equery/depends.py
+++ b/pym/gentoolkit/equery/depends.py
@@ -18,7 +18,7 @@ from gentoolkit.dependencies import Dependencies
 from gentoolkit.equery import format_options, mod_usage, CONFIG
 from gentoolkit.helpers import get_cpvs, get_installed_cpvs
 from gentoolkit.cpv import CPV
-from gentoolkit.package import PackageFormatter, FORMAT_TMPL_VARS
+from gentoolkit.package import PackageFormatter, Package
 
 # ===
 # Globals



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

2022-07-10 Thread Brian Dolbec
commit: c1c66b84d3e14b887b7b460111664e62238172fb
Author: Alexander Miller  gmx  de>
AuthorDate: Sun Jul 10 15:55:25 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 15:55:25 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c1c66b84

equery check: Fix exception handling for Insufficient permissions

A quick look into the source reveals that there is actually code to handle the 
case,
but it expects the wrong exception type.
This patch fixes that and also avoids a crash for other errors.

Bug: https://bugs.gentoo.org/494134
Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/check.py | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py
index 7a7c3db..7e580b1 100644
--- a/pym/gentoolkit/equery/check.py
+++ b/pym/gentoolkit/equery/check.py
@@ -16,6 +16,7 @@ from functools import partial
 from getopt import gnu_getopt, GetoptError
 
 import portage.checksum as checksum
+from portage.exception import PermissionDenied
 
 import gentoolkit.pprinter as pp
 from gentoolkit import errors
@@ -138,10 +139,14 @@ class VerifyContents:
 md5sum = files[cfile][2]
 try:
 cur_checksum = checksum.perform_md5(real_cfile, calc_prelink=1)
-except IOError:
+except PermissionDenied:
 err = "Insufficient permissions to read %(cfile)s"
 obj_errs.append(err % locals())
 return obj_errs
+except Exception as ex:
+err = "Problem checking %(cfile)s: %(ex)s"
+obj_errs.append(err % locals())
+return obj_errs
 if cur_checksum != md5sum:
 err = "%(cfile)s has incorrect MD5sum"
 obj_errs.append(err % locals())



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

2022-07-10 Thread Brian Dolbec
commit: 9b9711bf1bd0bdc24e4be6fc226758738d7a
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Jul 10 16:16:40 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 16:16:40 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=9b9711bf

equery depends: Fix a traceback due to UnboundLocalError:

  File "/home/brian/Dev/git/gentoolkit/pym/gentoolkit/equery/depends.py"
  , line 106, in format_depend
self.print_fn(indent, str(dep.cpv), use_conditional, formatted_dep)
UnboundLocalError: local variable 'formatted_dep' referenced before
assignment

The statement appears to be added as preliminary debug info.
Removed it.

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/depends.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py
index f65e846..fe56148 100644
--- a/pym/gentoolkit/equery/depends.py
+++ b/pym/gentoolkit/equery/depends.py
@@ -103,7 +103,6 @@ class DependPrinter:
 pkg = Package(str(dep.cpv))
 self.print_formated(pkg)
 else:
-self.print_fn(indent, str(dep.cpv), use_conditional, formatted_dep)
 if mdep.use_conditional:
 use_conditional = " & ".join(
 pp.useflag(u) for u in mdep.use_conditional.split()



[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/

2022-07-09 Thread Brian Dolbec
commit: 84ffe42e52d06fd90a21c93d60dbec7c64b621cf
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Jul 10 01:06:50 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 01:06:50 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=84ffe42e

equery: Turn off color when piping is set

Bug: https://bugs.gentoo.org/506394

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/__init__.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pym/gentoolkit/equery/__init__.py 
b/pym/gentoolkit/equery/__init__.py
index cecb5be..56b2caa 100644
--- a/pym/gentoolkit/equery/__init__.py
+++ b/pym/gentoolkit/equery/__init__.py
@@ -228,6 +228,8 @@ def initialize_configuration():
 # set extra wide, should disable wrapping unless
 # there is some extra long text
 CONFIG["termWidth"] = 600
+# turn off color
+pp.output.nocolor()
 
 CONFIG["debug"] = bool(os.getenv("DEBUG", False))
 



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

2022-07-08 Thread Sam James
commit: 3851c6ea2fe93ee1d190adc13f3cfaef0901c982
Author: Sam James  gentoo  org>
AuthorDate: Sat Jul  9 05:17:34 2022 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Jul  9 05:17:34 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=3851c6ea

equery: run black

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

 pym/gentoolkit/equery/depends.py | 47 
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py
index 93f0ec1..f65e846 100644
--- a/pym/gentoolkit/equery/depends.py
+++ b/pym/gentoolkit/equery/depends.py
@@ -19,6 +19,7 @@ from gentoolkit.equery import format_options, mod_usage, 
CONFIG
 from gentoolkit.helpers import get_cpvs, get_installed_cpvs
 from gentoolkit.cpv import CPV
 from gentoolkit.package import PackageFormatter, FORMAT_TMPL_VARS
+
 # ===
 # Globals
 # ===
@@ -69,18 +70,18 @@ class DependPrinter:
 if pkg is None:
 return
 
-if CONFIG['verbose']:
-print (PackageFormatter(
-pkg,
-do_format=True,
-custom_format=QUERY_OPTS["package_format"]
-))
+if CONFIG["verbose"]:
+print(
+PackageFormatter(
+pkg, do_format=True, 
custom_format=QUERY_OPTS["package_format"]
+)
+)
 else:
-print (PackageFormatter(
-pkg,
-do_format=False,
-custom_format=QUERY_OPTS["package_format"]
-))
+print(
+PackageFormatter(
+pkg, do_format=False, 
custom_format=QUERY_OPTS["package_format"]
+)
+)
 
 def format_depend(self, dep, dep_is_displayed):
 """Format a dependency for printing.
@@ -107,24 +108,23 @@ class DependPrinter:
 use_conditional = " & ".join(
 pp.useflag(u) for u in mdep.use_conditional.split()
 )
-if mdep.operator == '=*':
-formatted_dep = '=%s*' % str(mdep.cpv)
+if mdep.operator == "=*":
+formatted_dep = "=%s*" % str(mdep.cpv)
 else:
 formatted_dep = mdep.operator + str(mdep.cpv)
 if mdep.slot:
-formatted_dep += pp.emph(':') + pp.slot(mdep.slot)
+formatted_dep += pp.emph(":") + pp.slot(mdep.slot)
 if mdep.sub_slot:
-formatted_dep += pp.slot('/') + pp.slot(mdep.sub_slot)
+formatted_dep += pp.slot("/") + pp.slot(mdep.sub_slot)
 if mdep.use:
-useflags = pp.useflag(','.join(mdep.use.tokens))
-formatted_dep += (pp.emph('[') + useflags + pp.emph(']'))
+useflags = pp.useflag(",".join(mdep.use.tokens))
+formatted_dep += pp.emph("[") + useflags + pp.emph("]")
 
 if dep_is_displayed:
 indent = indent + " " * len(str(dep.cpv))
-self.print_fn(indent, '', use_conditional, formatted_dep)
+self.print_fn(indent, "", use_conditional, formatted_dep)
 else:
-self.print_fn(indent, \
-str(dep.cpv), use_conditional, formatted_dep)
+self.print_fn(indent, str(dep.cpv), use_conditional, 
formatted_dep)
 
 
 # =
@@ -174,7 +174,7 @@ def parse_module_options(module_opts):
 QUERY_OPTS["include_masked"] = True
 elif opt in ("-D", "--indirect"):
 QUERY_OPTS["only_direct"] = False
-elif opt in ('-F', '--format'):
+elif opt in ("-F", "--format"):
 QUERY_OPTS["package_format"] = posarg
 elif opt in ("--depth"):
 if posarg.isdigit():
@@ -190,9 +190,8 @@ def parse_module_options(module_opts):
 
 def main(input_args):
 """Parse input and run the program"""
-short_opts = "hadDF:" # -d, --direct was old option for default action
-long_opts = ('help', 'all-packages', 'direct', 'indirect', \
-'format', 'depth=')
+short_opts = "hadDF:"  # -d, --direct was old option for default action
+long_opts = ("help", "all-packages", "direct", "indirect", "format", 
"depth=")
 
 try:
 module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)



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

2022-07-08 Thread Brian Dolbec
commit: 6a9be2d05751558d7d34e900dfc06a721278b447
Author: Martin Matous  matous  dev>
AuthorDate: Sat Jul  9 03:05:58 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sat Jul  9 03:10:24 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=6a9be2d0

equery: update linguas->l10n option

Signed-off-by: Martin Matous  matous.dev>

Signed-off-by: Brian Dolbec  gentoo.org>

 man/equery.1  | 4 ++--
 pym/gentoolkit/equery/uses.py | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/man/equery.1 b/man/equery.1
index 83aba0d..ee7ad7b 100644
--- a/man/equery.1
+++ b/man/equery.1
@@ -547,9 +547,9 @@ Display all package versions. Without this option, 
\fBequery\fP will choose the
 .br
 Show the forced and masked USE flags
 .HP
-.B \-i, \-\-ignore\-linguas
+.B \-i, \-\-ignore\-l10n
 .br
-Do not show the linguas USE flags
+Do not show the l10n USE flags
 .P
 .I R "EXAMPLES" ":"
 .EX

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 7af7f43..89f011c 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -215,8 +215,7 @@ def get_output_descriptions(pkg, global_usedesc):
 
 if QUERY_OPTS["ignore_l10n"]:
 for a in usevar[:]:
-# TODO: Remove linguas after transition to l10n is complete
-if a.startswith("l10n_") or a.startswith("linguas_"):
+if a.startswith("l10n_"):
 usevar.remove(a)
 
 if pkg.is_installed():



[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/, man/

2021-07-16 Thread Matt Turner
commit: 55170b5be88df6d5d8f6e07ecb39fc1a86d3426a
Author: Matt Turner  gentoo  org>
AuthorDate: Fri Jul 16 21:21:44 2021 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Jul 16 21:21:44 2021 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=55170b5b

equery: Remove leftovers from 'changes' removal

Closes: https://bugs.gentoo.org/796986
Fixes: bcb8158 ("equery: Remove 'changes' subcommand")
Signed-off-by: Matt Turner  gentoo.org>

 man/equery.1  | 48 ---
 pym/gentoolkit/equery/__init__.py |  1 -
 2 files changed, 49 deletions(-)

diff --git a/man/equery.1 b/man/equery.1
index 3b85bee..f7a5deb 100644
--- a/man/equery.1
+++ b/man/equery.1
@@ -87,54 +87,6 @@ Tell
 .B emerge
 to reinstall or update any package that installed a file matching a regular 
expression.
 
-.SS
-.BI "changes (c) [OPTIONS] " "PKG"
-Display the Gentoo ChangeLog entry for the latest installable version of 
\fIPKG\fP.
-
-.I R "LOCAL OPTIONS" ":"
-.HP
-.B \-l, \-\-latest
-.br
-Display only the latest ChangeLog entry. It's not uncommon for changes to be 
prepended to the ChangeLog without a version header if the changes did not 
require a version bump. Use this option to display such entries.
-.HP
-.B \-f, \-\-full
-.br
-Display the full ChangeLog.
-.br
-\fBHint\fP: Try piping (|) the output to a pager, like 'less'.
-.HP
-.BI "\-\-limit=" "NUM"
-.br
-Limit the \fINUM\fP of entries displayed. Use  this option in conjunction with 
\fB\-\-full\fP. \fB\-\-limit=3\fP would display the three latest entries.
-.HP
-.BI "\-\-from=" "VER"
-.br
-Set which \fIVER\fP to display from. Using this option by itself is equivalent 
to passing \fBchanges\fP a ranged package atom, e.g., '>=foo/bar\-1.5'. It can 
be used in conjunction with \fB\-\-to\fP to request a more complex range of 
entries.
-.HP
-.BI "\-\-to=" "VER"
-.br
-Set which \fIVER\fP to display to. (See \fB\-\-from\fP)
-.P
-.I R "EXAMPLES" ":"
-.EX
-.HP
-equery changes portage
-.EE
-.br
-Display the Gentoo ChangeLog entry for the latest installable version of 
Portage.
-.EX
-.HP
-equery changes '=sys\-apps/portage\-2.1.6*'
-.EE
-.br
-Use Portage's atom syntax. (See \fBman 5 ebuild\fP)
-.EX
-.HP
-equery changes portage \-\-from=2.2_rc1 \-\-to=2.2
-.EE
-.br
-Display any ChangeLog entry within a range of versions.
-
 .SS
 .BI "check (k) [OPTIONS] " "PKG"
 Check timestamps and MD5 sums for files owned by \fIPKG\fP, where \fIPKG\fP is 
an installed package.

diff --git a/pym/gentoolkit/equery/__init__.py 
b/pym/gentoolkit/equery/__init__.py
index 677f534..e5b3deb 100644
--- a/pym/gentoolkit/equery/__init__.py
+++ b/pym/gentoolkit/equery/__init__.py
@@ -82,7 +82,6 @@ def print_help(with_description=True):
print(pp.command("modules") + " (" + pp.command("short name") + ")")
print(format_options((
(" (b)elongs", "list what package FILES belong to"),
-   (" (c)hanges", "list changelog entries for ATOM"),
(" chec(k)", "verify checksums and timestamps for PKG"),
(" (d)epends", "list all packages directly depending on ATOM"),
(" dep(g)raph", "display a tree of all dependencies for PKG"),



[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 

[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>" % 

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

2018-05-01 Thread Mike Pagano
commit: bb585671418fa51682a7e1dbfef5914e26261adf
Author: Mike Pagano  gentoo  org>
AuthorDate: Tue May  1 12:30:13 2018 +
Commit: Mike Pagano  gentoo  org>
CommitDate: Tue May  1 12:30:13 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=bb585671

epkginfo: Add 'reverse' display option for equery

This adds a small convenience for displaying the ebuilds in reverse
order.  This helps people prune packages that grow quickly as the
most relevant ones are at the top.

 pym/gentoolkit/equery/meta.py | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index ea1c96a..e9f5cea 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -89,6 +89,7 @@ def print_help(with_description=True, with_usage=True):
(" -k, --keywords", "show keywords for all matching package 
versions"),
(" -l, --license", "show licenses for the best maching 
version"),
(" -m, --maintainer", "show the maintainer(s) for the package"),
+   (" -r, --reverse", "show the output in reverse order if 
applicable"),
(" -S, --stablreq", "show STABLEREQ arches (cc's) for all 
matching package versions"),
(" -u, --useflags", "show per-package USE flag descriptions"),
(" -U, --upstream", "show package's upstream information"),
@@ -525,9 +526,9 @@ def parse_module_options(module_opts):
 def main(input_args):
"""Parse input and run the program."""
 
-   short_opts = "hdHklmSuUx"
+   short_opts = "hdHklmrSuUx"
long_opts = ('help', 'description', 'herd', 'keywords', 'license',
-   'maintainer', 'stablereq', 'useflags', 'upstream', 'xml')
+   'maintainer', 'reverse', 'stablereq', 'useflags', 'upstream', 
'xml')
 
try:
module_opts, queries = gnu_getopt(input_args, short_opts, 
long_opts)
@@ -561,6 +562,8 @@ def main(input_args):
print()
 
matches.sort()
+   matches.sort(reverse=any(name in ('-r', '--reverse')
+   for name, opt in module_opts))
call_format_functions(best_match, matches)
 
first_run = False



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

2017-09-05 Thread Mike Gilbert
commit: 83b757c0b7bcf1912eb1acabdfbb3f5a5f46cd17
Author: Mike Gilbert  gentoo  org>
AuthorDate: Tue May 23 22:46:32 2017 +
Commit: Mike Gilbert  gentoo  org>
CommitDate: Tue May 23 22:49:07 2017 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=83b757c0

equery: check: use os.path.lexists()

os.path.exists() returns false on broken symlinks. We don't actually
care if the symlink target exists.

X-Gentoo-Bug: 619472
X-Gentoo-Bug-URL: https://bugs.gentoo.org/619472

 pym/gentoolkit/equery/check.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py
index 77042f8..d5a22a3 100644
--- a/pym/gentoolkit/equery/check.py
+++ b/pym/gentoolkit/equery/check.py
@@ -106,7 +106,7 @@ class VerifyContents(object):
n_checked += 1
ftype = files[cfile][0]
real_cfile = os.environ.get('ROOT', '') + cfile
-   if not os.path.exists(real_cfile):
+   if not os.path.lexists(real_cfile):
errs.append("%s does not exist" % cfile)
continue
elif ftype == "dir":



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

2016-06-30 Thread Paul Varner
commit: fa12fe254733ca3e6edf5659522da7e048f53adc
Author: Paul Varner  gentoo  org>
AuthorDate: Thu Jun 30 21:06:00 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Thu Jun 30 21:19:10 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=fa12fe25

equery: Change option --ignore-linguas to --ignore-l10n

Change the option to filter out the L10N USE expanded flag. This is to
support the transition from using LINGUAS for localization in ebuilds.

 pym/gentoolkit/equery/uses.py | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index adf8b6c..79f1118 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -35,7 +35,7 @@ from gentoolkit.flag import get_flags, reduce_flags
 # Globals
 # ===
 
-QUERY_OPTS = {"all_versions" : False, "ignore_linguas" : False}
+QUERY_OPTS = {"all_versions" : False, "ignore_l10n" : False}
 
 # =
 # Functions
@@ -57,7 +57,7 @@ def print_help(with_description=True):
print(format_options((
(" -h, --help", "display this help message"),
(" -a, --all", "include all package versions"),
-   (" -i, --ignore-linguas", "don't show linguas USE flags")
+   (" -i, --ignore-l10n", "don't show l10n USE flags")
)))
 
 
@@ -187,9 +187,10 @@ def get_output_descriptions(pkg, global_usedesc):
usevar = reduce_flags(iuse)
usevar.sort()
 
-   if QUERY_OPTS['ignore_linguas']:
+   if QUERY_OPTS['ignore_l10n']:
for a in usevar[:]:
-   if a.startswith("linguas_"):
+   #TODO: Remove linguas after transition to l10n is 
complete
+   if a.startswith("l10n_") or a.startswith("linguas_"):
usevar.remove(a)
 
 
@@ -244,8 +245,8 @@ def parse_module_options(module_opts):
sys.exit(0)
elif opt in ('-a', '--all'):
QUERY_OPTS['all_versions'] = True
-   elif opt in ('-i', '--ignore-linguas'):
-   QUERY_OPTS['ignore_linguas'] = True
+   elif opt in ('-i', '--ignore-l10n'):
+   QUERY_OPTS['ignore_l10n'] = True
 
 
 def print_legend():
@@ -261,7 +262,7 @@ def main(input_args):
"""Parse input and run the program"""
 
short_opts = "hai"
-   long_opts = ('help', 'all', 'ignore-linguas')
+   long_opts = ('help', 'all', 'ignore-l10n')
 
try:
module_opts, queries = gnu_getopt(input_args, short_opts, 
long_opts)



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

2016-06-30 Thread Paul Varner
commit: b72e032ea252757c4309516c865fafaf7354036b
Author: Paul Varner  gentoo  org>
AuthorDate: Thu Jun 30 20:39:24 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Thu Jun 30 20:39:24 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b72e032e

equery: Fix UnicodeDecodeError in python2.7

This fix explicitly decodes the content of the USE description files as
UTF-8. This fixes the UnicodeDecodeError in Python 2.7. Tested with a
POSIX locale with Python 2.7, 3.4 and 3.5.

X-Gentoo-bug: 587606
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=587606

 pym/gentoolkit/equery/uses.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 79ed00f..adf8b6c 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -138,6 +138,7 @@ def get_global_useflags():
path = os.path.join(settings["PORTDIR"], 'profiles', 'use.desc')
with open(_unicode_encode(path, encoding=_encodings['fs'])) as 
open_file:
for line in open_file:
+   line = _unicode_decode(line)
if line.startswith('#'):
continue
# Ex. of fields: ['syslog', 'Enables support 
for syslog\n']
@@ -158,6 +159,7 @@ def get_global_useflags():
try:
with open(_unicode_encode(path, 
encoding=_encodings['fs'])) as open_file:
for line in open_file:
+   line = _unicode_decode(line)
if line.startswith('#'):
continue
fields = [field.strip() for field in 
line.split(" - ", 1)]



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

2016-06-06 Thread Brian Dolbec
commit: b502f01a5906602abf08e08c7a5d948518df055a
Author: Brian Dolbec  gentoo  org>
AuthorDate: Mon Jun  6 15:29:33 2016 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Mon Jun  6 15:29:33 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b502f01a

equery.depends.py: Apply subslot patch from bug 576060

Author: Jelte Fennema  jeltef.nl>
X-Gentoo-bug: 576060
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=576060

 pym/gentoolkit/equery/depends.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py
index 9e5d8de..93c2137 100644
--- a/pym/gentoolkit/equery/depends.py
+++ b/pym/gentoolkit/equery/depends.py
@@ -91,6 +91,8 @@ class DependPrinter(object):
formatted_dep = mdep.operator + str(mdep.cpv)
if mdep.slot:
formatted_dep += pp.emph(':') + pp.slot(mdep.slot)
+   if mdep.sub_slot:
+   formatted_dep += pp.slot('/') + 
pp.slot(mdep.sub_slot)
if mdep.use:
useflags = pp.useflag(','.join(mdep.use.tokens))
formatted_dep += (pp.emph('[') + useflags + 
pp.emph(']'))



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

2015-11-09 Thread Brian Dolbec
commit: 62c9856745e5b6de230d4ede5e8d7e9ff226ff73
Author: Brian Dolbec  gentoo  org>
AuthorDate: Mon Nov  9 20:51:37 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Mon Nov  9 20:51:37 2015 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=62c98567

equery/meta.py: Re-add the coma, so it makes the data a true tuple.

As pointed out by Arfrever Frehtes Taifersar Arahesis, this prides protection 
in that if the 
variable's data is a tuple.  The conversion will still happen correctly.

 pym/gentoolkit/equery/meta.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index 8af5744..ea1c96a 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -181,9 +181,9 @@ def format_maintainers(maints):
for maint in maints:
maintstr = maint.email or ''
if CONFIG['verbose']:
-   maintstr += " (%s)" % (maint.name) if maint.name else ''
-   maintstr += " - %s" % (maint.restrict) if 
maint.restrict else ''
-   maintstr += "\n%s" % (maint.description) if 
maint.description else ''
+   maintstr += " (%s)" % (maint.name,) if maint.name else 
''
+   maintstr += " - %s" % (maint.restrict,) if 
maint.restrict else ''
+   maintstr += "\n%s" % (maint.description,) if 
maint.description else ''
result.append(maintstr)
 
return result



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

2015-11-08 Thread Brian Dolbec
commit: 8f226fd87cc96c997a6be5adb29ed6e6787d0791
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Nov  8 17:15:03 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Nov  8 17:36:27 2015 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=8f226fd8

equery/meta.py: Fix a traceback reported by Manuel Rueger

equery m python-whiteboard
 * x11-apps/python-whiteboard [gentoo]
Herd:proxy-maintainers (proxy-maint  gentoo.org)
Maintainer:  lxnay  gentoo.org (Fabio Erculiani)
 Maintainer. Assign bugs to him
Maintainer:  ziapannocchia  gmail.com (Marco Clocchiatti)
 Proxy maintainer. CC him on bugs
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/equery", line 38, in 
equery.main(sys.argv)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/__init__.py", line 
357, in main
loaded_module.main(module_args)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/meta.py", line 
567, in main
call_format_functions(best_match, matches)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/meta.py", line 
338, in call_format_functions
upstream = format_upstream(best_match.metadata.upstream())
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/meta.py", line 
220, in format_upstream
upmaints = format_maintainers(up.maintainers)
  File "/usr/lib64/python2.7/site-packages/gentoolkit/equery/meta.py", line 
185, in format_maintainers
maintstr += " (%s)" % (maint.name,) if maint.name else ''
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

Signed-off-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/equery/meta.py | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index d3342cd..1a07999 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -179,14 +179,11 @@ def format_maintainers(maints):
 
result = []
for maint in maints:
-   maintstr = ''
-   maintstr = maint.email
+   maintstr = maint.email or ''
if CONFIG['verbose']:
-   maintstr += " (%s)" % (maint.name,) if maint.name else 
''
-   maintstr += " - %s" % (maint.restrict,) if 
maint.restrict else ''
-   maintstr += "\n%s" % (
-   (maint.description,) if maint.description else 
''
-   )
+   maintstr += " (%s)" % (maint.name or'')
+   maintstr += " - %s" % (maint.restrict or '')
+   maintstr += "\n%s" % (maint.description or '')
result.append(maintstr)
 
return result



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

2015-11-08 Thread Brian Dolbec
commit: ddb7cf01f01d7175cdab348b9d94b0994695e337
Author: Brian Dolbec  gentoo  org>
AuthorDate: Mon Nov  9 02:37:15 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Mon Nov  9 02:37:15 2015 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=ddb7cf01

equery/meta.py: Revert the changes to the verbose section or format_maintainers

The last change would always print the first string even if the maint attribute 
was None.
This was due to the string always being non-empty.
The original code there was correct.
It was only the maint.email assignment that was in error.

 pym/gentoolkit/equery/meta.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index 1a07999..8af5744 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -181,9 +181,9 @@ def format_maintainers(maints):
for maint in maints:
maintstr = maint.email or ''
if CONFIG['verbose']:
-   maintstr += " (%s)" % (maint.name or'')
-   maintstr += " - %s" % (maint.restrict or '')
-   maintstr += "\n%s" % (maint.description or '')
+   maintstr += " (%s)" % (maint.name) if maint.name else ''
+   maintstr += " - %s" % (maint.restrict) if 
maint.restrict else ''
+   maintstr += "\n%s" % (maint.description) if 
maint.description else ''
result.append(maintstr)
 
return result