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

2022-07-09 Thread Brian Dolbec
commit: 8c9b533343801fcab49a150c1e49dddf7bdaf4f3
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Jul 10 01:21:14 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Jul 10 01:21:14 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=8c9b5333

Fix typo "informations" revdep-rebuild & eshowkw

original Author: buchner.johannes  gmx.at
Bug: https://bugs.gentoo.org/648444

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

 pym/gentoolkit/eshowkw/keywords_content.py | 2 +-
 pym/gentoolkit/revdep_rebuild/analyse.py   | 2 +-
 pym/gentoolkit/revdep_rebuild/settings.py  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_content.py 
b/pym/gentoolkit/eshowkw/keywords_content.py
index 4f9e3e1..d70be72 100644
--- a/pym/gentoolkit/eshowkw/keywords_content.py
+++ b/pym/gentoolkit/eshowkw/keywords_content.py
@@ -106,7 +106,7 @@ class keywords_content:
 return [self.__separateVersion(x, repo, revlength) for x, repo in 
packages]
 
 def __getRevision(self, cpv):
-"""Get revision informations for each package for nice further 
alignment"""
+"""Get revision information for each package for nice further 
alignment"""
 rev = port.catpkgsplit(cpv)[3]
 return rev if rev != "r0" else ""
 

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py 
b/pym/gentoolkit/revdep_rebuild/analyse.py
index c9c4a77..b176943 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -384,7 +384,7 @@ def analyse(
 ftime = current_milli_time()
 logger.debug("\ttime to complete task: %d milliseconds" % (ftime - 
stime))
 stime = current_milli_time()
-logger.info(green(" * ") + bold("Collecting dynamic linking 
informations"))
+logger.info(green(" * ") + bold("Collecting dynamic linking 
information"))
 
 libraries, la_libraries, libraries_links = collect_libraries_from_dir(
 lib_dirs, all_masks, logger

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py 
b/pym/gentoolkit/revdep_rebuild/settings.py
index 5551855..2a880fd 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -64,7 +64,7 @@ def parse_options():
 "-V",
 "--version",
 action="version",
-help="Show version informations",
+help="Show version information",
 version="%(prog)s " + VERSION,
 )
 
@@ -116,7 +116,7 @@ def parse_options():
 help="Be more verbose (also passed to emerge command)",
 )
 parser.add_argument(
-"-d", "--debug", action="store_true", help="Print debug informations"
+"-d", "--debug", action="store_true", help="Print debug information"
 )
 
 parser.add_argument("portage_options", nargs="*")



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

2022-07-08 Thread Mike Gilbert
commit: 707b0340d69da92d6e3c72892c190a1e3fd0c2e1
Author: Mike Gilbert  gentoo  org>
AuthorDate: Sat Jul  9 01:35:41 2022 +
Commit: Mike Gilbert  gentoo  org>
CommitDate: Sat Jul  9 01:35:41 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=707b0340

eshowkw: make black happy

Signed-off-by: Mike Gilbert  gentoo.org>

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

diff --git a/pym/gentoolkit/eshowkw/display_pretty.py 
b/pym/gentoolkit/eshowkw/display_pretty.py
index 82fd446..9a769f9 100644
--- a/pym/gentoolkit/eshowkw/display_pretty.py
+++ b/pym/gentoolkit/eshowkw/display_pretty.py
@@ -125,6 +125,6 @@ class string_rotator:
 if x.find("+ -") != -1:
 x = x.replace(" ", "-")
 # strip all chars and remove empty lines
-if not strip or len(x.strip(" |-")) > 0 or '-' in x:
+if not strip or len(x.strip(" |-")) > 0 or "-" in x:
 tmp.append(x)
 return tmp



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

2022-06-08 Thread Brian Dolbec
commit: 84fc1ec271328e064da8b2537112b724e5a4c3b5
Author: Brian Dolbec  gentoo  org>
AuthorDate: Wed Jun  8 20:06:01 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Wed Jun  8 20:06:01 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=84fc1ec2

eshowkw: Fix missing dash for -r? ebuilds in versionlist output

Turns out the real issue causing the row alignment issue was this.
The code inadvertently dropped the dash display which in turn caused the
 row alignment issue.

 Reverts: 4695379c1921865d7763669580ac909ea94db90d
 Gentoo-bug-url: https://bugs.gentoo.org/503366

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

 pym/gentoolkit/eshowkw/__init__.py   | 2 +-
 pym/gentoolkit/eshowkw/display_pretty.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index c33c47a..ba6c076 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -49,7 +49,7 @@ def process_display(package, keywords, dbapi):
 content.extend(sep)
 content.extend(keywords.extra)
 header_length = keywords.length
-content_length = portdata.version_length - 1
+content_length = portdata.version_length
 display(content, header, header_length, content_length, portdata.cp, 
topper)
 
 

diff --git a/pym/gentoolkit/eshowkw/display_pretty.py 
b/pym/gentoolkit/eshowkw/display_pretty.py
index 0629d7e..82fd446 100644
--- a/pym/gentoolkit/eshowkw/display_pretty.py
+++ b/pym/gentoolkit/eshowkw/display_pretty.py
@@ -125,6 +125,6 @@ class string_rotator:
 if x.find("+ -") != -1:
 x = x.replace(" ", "-")
 # strip all chars and remove empty lines
-if not strip or len(x.strip(" |-")) > 0:
+if not strip or len(x.strip(" |-")) > 0 or '-' in x:
 tmp.append(x)
 return tmp



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

2022-06-07 Thread Brian Dolbec
commit: 4695379c1921865d7763669580ac909ea94db90d
Author: Brian Dolbec  gentoo  org>
AuthorDate: Wed Jun  8 01:16:13 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Wed Jun  8 01:16:13 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=4695379c

eshowkw: Correctly fix row alignment issue bug 503366

Reverts: 42cf522c06080d
Changes the content_length correctly for versionlist output

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

 pym/gentoolkit/eshowkw/__init__.py   | 2 +-
 pym/gentoolkit/eshowkw/display_pretty.py | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index ba6c076..c33c47a 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -49,7 +49,7 @@ def process_display(package, keywords, dbapi):
 content.extend(sep)
 content.extend(keywords.extra)
 header_length = keywords.length
-content_length = portdata.version_length
+content_length = portdata.version_length - 1
 display(content, header, header_length, content_length, portdata.cp, 
topper)
 
 

diff --git a/pym/gentoolkit/eshowkw/display_pretty.py 
b/pym/gentoolkit/eshowkw/display_pretty.py
index 47d18d1..0629d7e 100644
--- a/pym/gentoolkit/eshowkw/display_pretty.py
+++ b/pym/gentoolkit/eshowkw/display_pretty.py
@@ -29,8 +29,7 @@ def display(
 # data
 corner_image = ["".ljust(plain_width) for x in range(rotated_height)]
 if toplist != "archlist":
-# DON'T add the first list item which is: "---", it will throw the 
row alignment off
-corner_image.extend(plain_list[1:])
+corner_image.extend(plain_list)
 data_printout = [
 "%s%s" % (x, y)
 for x, y in zip_longest(corner_image, rotated_list, 
fillvalue=corner_image[0])



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

2022-06-07 Thread Brian Dolbec
commit: 42cf522c06080d3b92d7c87d3e00d93d3a7e1a7f
Author: Brian Dolbec  gentoo  org>
AuthorDate: Tue Jun  7 23:55:35 2022 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Wed Jun  8 00:09:54 2022 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=42cf522c

eshowkw: Fix bug 503366 row alignment issue

The first element in the plain_list was a "--" string.  This was causing
the corner image to throw off the row alignment between the two columns.
This fix corrects the alignment, but removes the "--" above the keywords
to complete the header seperator line.

Gentoo-bug-url: https://bugs.gentoo.org/503366

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

 pym/gentoolkit/eshowkw/display_pretty.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/display_pretty.py 
b/pym/gentoolkit/eshowkw/display_pretty.py
index d58036a..47d18d1 100644
--- a/pym/gentoolkit/eshowkw/display_pretty.py
+++ b/pym/gentoolkit/eshowkw/display_pretty.py
@@ -1,4 +1,4 @@
-#  vim:fileencoding=utf-8
+#   vim:fileencoding=utf-8
 # Copyright 2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
@@ -29,7 +29,8 @@ def display(
 # data
 corner_image = ["".ljust(plain_width) for x in range(rotated_height)]
 if toplist != "archlist":
-corner_image.extend(plain_list)
+# DON'T add the first list item which is: "---", it will throw the 
row alignment off
+corner_image.extend(plain_list[1:])
 data_printout = [
 "%s%s" % (x, y)
 for x, y in zip_longest(corner_image, rotated_list, 
fillvalue=corner_image[0])



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

2020-01-26 Thread Michał Górny
commit: e98fd5881b7248670cb9c8a4daff537551e1d55e
Author: Michał Górny  gentoo  org>
AuthorDate: Sun Jan 26 14:59:20 2020 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jan 26 14:59:32 2020 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e98fd588

eshowkw: Add alpha to ~arch-only

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

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index c17a777..f98f11a 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -81,7 +81,7 @@ def load_profile_data(portdir=None, repo='gentoo'):
# TODO: support arches.desc once the GLEP is finalized
# for now, we just hardcode ~mips + *-* (fbsd, prefix)
for k, v in arch_status.items():
-   if k in ('mips', 'riscv') or '-' in k:
+   if k in ('alpha', 'mips', 'riscv') or '-' in k:
arch_status[k] = (v, '~arch')
else:
arch_status[k] = (v, 'arch')



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

2019-05-11 Thread Michał Górny
commit: 31a8a27b0851c783bb7ec82d14435e5d7d0faf49
Author: Michał Górny  gentoo  org>
AuthorDate: Sat May 11 20:24:26 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat May 11 20:24:26 2019 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=31a8a27b

eshowkw: Add riscv to ~arch-only arches

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

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index ab9117e..c17a777 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -81,7 +81,7 @@ def load_profile_data(portdir=None, repo='gentoo'):
# TODO: support arches.desc once the GLEP is finalized
# for now, we just hardcode ~mips + *-* (fbsd, prefix)
for k, v in arch_status.items():
-   if k == 'mips' or '-' in k:
+   if k in ('mips', 'riscv') or '-' in k:
arch_status[k] = (v, '~arch')
else:
arch_status[k] = (v, 'arch')



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

2018-01-26 Thread Michał Górny
commit: 97595e02fc8eced9a1a54d246a4163fae6badcaf
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 12:30:02 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=97595e02

eshowkw: Sort pure ~arch arches after stable keyword arches

To match the new ordering on Bugzilla, order arches with pure ~arch
keywords after those having stable keywords. The idea behind it is to
make it easier to determine which arches to CC on stablereqs.

The pure ~arch arch list is hardcoded for now to mips + *-* (fbsd,
prefix). However, in the future it will be replaced by status defined
by arches.desc once that GLEP is finalized.

 pym/gentoolkit/eshowkw/keywords_header.py | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 1a1a422..c9f2381 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -15,7 +15,7 @@ from portage.output import colorize
 from gentoolkit.eshowkw.display_pretty import colorize_string
 from gentoolkit.eshowkw.display_pretty import align_string
 
-# Copied from ekeyword
+# Copied from ekeyword, modified to support arch vs ~arch status
 def load_profile_data(portdir=None, repo='gentoo'):
"""Load the list of known arches from the tree
 
@@ -25,7 +25,7 @@ def load_profile_data(portdir=None, repo='gentoo'):
 
Returns:
  A dict mapping the keyword to its preferred state:
- {'x86': 'stable', 'mips': 'dev', ...}
+ {'x86': ('stable', 'arch'), 'mips': ('dev', '~arch'), ...}
"""
if portdir is None:
portdir = 
portage.db[portage.root]['vartree'].settings.repositories[repo].location
@@ -71,16 +71,28 @@ def load_profile_data(portdir=None, repo='gentoo'):
warning('could not read profile files: %s' % arch_list)
warning('will not be able to verify args are correct')
 
+   # TODO: support arches.desc once the GLEP is finalized
+   # for now, we just hardcode ~mips + *-* (fbsd, prefix)
+   for k, v in arch_status.items():
+   if k == 'mips' or '-' in k:
+   arch_status[k] = (v, '~arch')
+   else:
+   arch_status[k] = (v, 'arch')
+
return arch_status
 
 def gen_arch_list(status):
_arch_status = load_profile_data()
if status == "stable":
-   return [arch for arch in _arch_status if _arch_status[arch] == 
"stable"]
+   return [arch for arch in _arch_status if _arch_status[arch][0] 
== "stable"]
elif status == "dev":
-   return [arch for arch in _arch_status if _arch_status[arch] == 
"dev"]
+   return [arch for arch in _arch_status if _arch_status[arch][0] 
== "dev"]
elif status == "exp":
-   return [arch for arch in _arch_status if _arch_status[arch] == 
"exp"]
+   return [arch for arch in _arch_status if _arch_status[arch][0] 
== "exp"]
+   elif status == "arch":
+   return [arch for arch in _arch_status if _arch_status[arch][1] 
== "arch"]
+   elif status == "~arch":
+   return [arch for arch in _arch_status if _arch_status[arch][1] 
== "~arch"]
else:
raise TypeError
 
@@ -88,6 +100,7 @@ class keywords_header:
__IMPARCHS = gen_arch_list("stable")
__DEV_ARCHS = gen_arch_list("dev")
__EXP_ARCHS = gen_arch_list("exp")
+   __TESTING_KW_ARCHS = gen_arch_list("~arch")
__ADDITIONAL_FIELDS = [ 'eapi', 'unused', 'slot' ]
__EXTRA_FIELDS = [ 'repo' ]
 
@@ -128,7 +141,13 @@ class keywords_header:
levels[kw] = level
break
 
-   normal.sort(key=lambda kw: (levels.get(kw, 99), kw.count('-'), 
kw))
+   # sort by, in order (to match Bugzilla):
+   # 1. arch, then ~arch
+   # 2. profile stability
+   # 3. short keywords, then long (prefix, fbsd)
+   # 4. keyword name
+   normal.sort(key=lambda kw: (kw in self.__TESTING_KW_ARCHS,
+   levels.get(kw, 99), kw.count('-'), kw))
return normal
 
def __readAdditionalFields(self):



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

2018-01-26 Thread Michał Górny
commit: 70b2518f12f63071f0192c23826188bd456698e7
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 21:42:19 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=70b2518f

eshowkw: Always group Prefix keywords last

Always group all Prefix keywords after other types of keywords. This
not only ensures that fbsd sorts first but more importantly stabilizes
the LHS output between regular and -P variant -- that is, -P always adds
additional keywords at the end.

 pym/gentoolkit/eshowkw/keywords_header.py | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index ce3e8d4..6557f60 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -142,12 +142,16 @@ class keywords_header:
break
 
# sort by, in order (to match Bugzilla):
-   # 1. arch, then ~arch
-   # 2. profile stability
-   # 3. short keywords, then long (prefix, fbsd)
-   # 4. keyword name in reverse component order
-   normal.sort(key=lambda kw: (kw in self.__TESTING_KW_ARCHS,
-   levels.get(kw, 99), kw.count('-'), 
list(reversed(kw.split('-')
+   # 1. non-prefix, then prefix (stable output between -P and not)
+   # 2. arch, then ~arch
+   # 3. profile stability
+   # 4. short keywords, then long (prefix, fbsd)
+   # 5. keyword name in reverse component order
+   normal.sort(key=lambda kw: (self.__isPrefix(kw),
+   kw in self.__TESTING_KW_ARCHS,
+   levels.get(kw, 99),
+   kw.count('-'),
+   list(reversed(kw.split('-')
return normal
 
def __readAdditionalFields(self):



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

2018-01-26 Thread Michał Górny
commit: 76eadba35e05de28ba52ea3f48b9651702ae293e
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 12:16:44 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=76eadba3

eshowkw: Remove meaningless duplicate sort of Prefix keywords

 pym/gentoolkit/eshowkw/keywords_header.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 9eedbcf..a4934bc 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -118,7 +118,6 @@ class keywords_header:
normal = [k for k in keywords if not self.__isPrefix(k)]
if prefix:
longer = [k for k in keywords if self.__isPrefix(k)]
-   longer.sort()
normal.extend(longer)
 
lists = self.__IMPARCHS, self.__DEV_ARCHS, self.__EXP_ARCHS



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

2018-01-26 Thread Michał Górny
commit: 1a7f870b68741331f69b07e8227685e70c964202
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 12:11:13 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:47 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=1a7f870b

eshowkw: Split Prefix keyword test into separate function

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 9c6538c..9b00d17 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -1,5 +1,5 @@
 #  vim:fileencoding=utf-8
-# Copyright 2001-2010 Gentoo Foundation
+# Copyright 2001-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ['keywords_header']
@@ -97,6 +97,10 @@ class keywords_header:
return [x for x in ports.archlist()
if not x.startswith('~')]
 
+   @staticmethod
+   def __isPrefix(k):
+   return len(k.split('-')) != 1
+
def __sortKeywords(self, keywords, prefix = False, required_keywords = 
[]):
"""Sort keywords: order by status (IMP, then DEV, then EXP, then
prefix), then by name."""
@@ -109,10 +113,9 @@ class keywords_header:
if len(tmpkeywords) != 0:
keywords = tmpkeywords
 
-   normal = [k for k in keywords if len(k.split('-')) == 1]
+   normal = [k for k in keywords if not self.__isPrefix(k)]
if prefix:
-   longer = [k for k in keywords
-   if len(k.split('-')) != 1]
+   longer = [k for k in keywords if self.__isPrefix(k)]
longer.sort()
normal.extend(longer)
 



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

2018-01-26 Thread Michał Górny
commit: ba6be5523dfd11bd675be2d705d0f6ba3dec3a0c
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 12:14:29 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=ba6be552

eshowkw: Sort all multi-component keywords after normal

Add component count (implied by the count of '-' separators) to sort
criteria. This ensures that *-fbsd sorts after regular arches, much like
we list it in Bugzilla.

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 86e9bc5..9eedbcf 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -129,7 +129,7 @@ class keywords_header:
levels[kw] = level
break
 
-   normal.sort(key=lambda kw: (levels.get(kw, 99), kw))
+   normal.sort(key=lambda kw: (levels.get(kw, 99), kw.count('-'), 
kw))
return normal
 
def __readAdditionalFields(self):



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

2018-01-26 Thread Michał Górny
commit: 6013556194c0af9cb5a61d9ffb9879c31c4669e9
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 21:38:46 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=60135561

eshowkw: Group Prefix keywords by system

Sort keywords by reversed component list rather than combined name,
in order to group Prefix keywords by system. Requested by Ulrich Müller.

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index c9f2381..ce3e8d4 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -145,9 +145,9 @@ class keywords_header:
# 1. arch, then ~arch
# 2. profile stability
# 3. short keywords, then long (prefix, fbsd)
-   # 4. keyword name
+   # 4. keyword name in reverse component order
normal.sort(key=lambda kw: (kw in self.__TESTING_KW_ARCHS,
-   levels.get(kw, 99), kw.count('-'), kw))
+   levels.get(kw, 99), kw.count('-'), 
list(reversed(kw.split('-')
return normal
 
def __readAdditionalFields(self):



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

2018-01-26 Thread Michał Górny
commit: 9dce326531f94f2f34865efce6eb7f0f5060d016
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 12:19:52 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=9dce3265

eshowkw: Group stable and dev arches together (to match Bugzilla)

Since dev profile status implies working towards stable status, and we
are currently working on improving the status of dev arches
(in particular preventing new depgraph breakages from being committed),
we have switched Bugzilla to display both statuses alongside. Update
eshowkw to use the same output ordering.

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index a4934bc..1a1a422 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -120,7 +120,7 @@ class keywords_header:
longer = [k for k in keywords if self.__isPrefix(k)]
normal.extend(longer)
 
-   lists = self.__IMPARCHS, self.__DEV_ARCHS, self.__EXP_ARCHS
+   lists = (self.__IMPARCHS + self.__DEV_ARCHS), self.__EXP_ARCHS
levels = {}
for kw in normal:
for level, ls in enumerate(lists):



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

2018-01-26 Thread Michał Górny
commit: ed4a76633d69d6312b8572bc16cc758cbc36b94e
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jan 23 12:12:59 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 26 14:50:50 2018 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=ed4a7663

eshowkw: Stop wrongly classifying *-fbsd as Prefix

 pym/gentoolkit/eshowkw/keywords_header.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 9b00d17..86e9bc5 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -99,7 +99,9 @@ class keywords_header:
 
@staticmethod
def __isPrefix(k):
-   return len(k.split('-')) != 1
+   spl = k.split('-')
+   # *-fbsd are not prefix
+   return len(spl) > 1 and spl[1] != 'fbsd'
 
def __sortKeywords(self, keywords, prefix = False, required_keywords = 
[]):
"""Sort keywords: order by status (IMP, then DEV, then EXP, then



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

2016-11-23 Thread Zac Medico
commit: b4c059f6908965981816134d97d68e528ecbe75e
Author: Zac Medico  gentoo  org>
AuthorDate: Tue Nov 22 17:45:28 2016 +
Commit: Zac Medico  gentoo  org>
CommitDate: Wed Nov 23 23:24:09 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b4c059f6

eshowkw: distinguish repository of installed package (bug 600486)

X-Gentoo-bug: 600486
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=600486
Acked-by: Brian Dolbec  gentoo.org>

 pym/gentoolkit/eshowkw/keywords_content.py | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_content.py 
b/pym/gentoolkit/eshowkw/keywords_content.py
index b6ad118..18926b4 100644
--- a/pym/gentoolkit/eshowkw/keywords_content.py
+++ b/pym/gentoolkit/eshowkw/keywords_content.py
@@ -101,21 +101,21 @@ class keywords_content:
class VersionChecker:
def __getVersions(self, packages):
"""Obtain properly aligned version strings without 
colors."""
-   revlength = max([len(self.__getRevision(x)) for x in 
packages])
-   return  [self.__separateVersion(x, revlength) for x in 
packages]
+   revlength = max([len(self.__getRevision(x)) for x, repo 
in packages])
+   return  [self.__separateVersion(x, repo, revlength) for 
x, repo in packages]
 
def __getRevision(self, cpv):
"""Get revision informations for each package for nice 
further alignment"""
rev = port.catpkgsplit(cpv)[3]
return rev if rev != 'r0' else ''
 
-   def __separateVersion(self, cpv, revlength):
-   return self.__modifyVersionInfo(cpv, 
port.versions.cpv_getversion(cpv), revlength)
+   def __separateVersion(self, cpv, repo, revlength):
+   return self.__modifyVersionInfo(cpv, repo, 
port.versions.cpv_getversion(cpv), revlength)
 
-   def __modifyVersionInfo(self, cpv, pv, revlength):
+   def __modifyVersionInfo(self, cpv, repo, pv, revlength):
"""Prefix and suffix version with string based on 
whether version is installed or masked and its revision."""
mask = self.__getMaskStatus(cpv)
-   install = self.__getInstallStatus(cpv)
+   install = self.__getInstallStatus(cpv, repo)
 
# calculate suffix length
currevlen = len(self.__getRevision(cpv))
@@ -149,9 +149,9 @@ class keywords_content:
return False
 
 
-   def __getInstallStatus(self, cpv):
+   def __getInstallStatus(self, cpv, repo):
"""Check if package version we test is installed."""
-   return self.vartree.cpv_exists(cpv)
+   return bool(self.vartree.match("=%s::%s" % (cpv, repo)))
 
def __init__(self, packages):
"""Query all relevant data for version data 
formatting"""
@@ -344,7 +344,7 @@ class keywords_content:
self.slot_length = max([len(x) for x in self.slots])
repositories_length = max([len(x) for x in self.repositories])
self.keyword_length = len(keywords_list)
-   vers =self.VersionChecker(packages)
+   vers =self.VersionChecker(list(zip(packages, 
self.repositories)))
self.versions = vers.versions
masks = vers.masks
self.version_length = max([len(x) for x in self.versions])



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

2016-07-03 Thread Zac Medico
commit: bb6912e1264137a3ba52d4fdc491ab26b2644a07
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Jul  3 17:55:43 2016 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Jul  3 17:59:13 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=bb6912e1

eshowkw: remove unused portage.db import

 pym/gentoolkit/eshowkw/__init__.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index 42a3860..707c266 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -12,7 +12,6 @@ from portage import output as porto
 from portage import settings as ports
 from portage import config as portc
 from portage import portdbapi as portdbapi
-from portage import db as portdb
 
 from gentoolkit.eshowkw.keywords_header import keywords_header
 from gentoolkit.eshowkw.keywords_content import keywords_content



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

2016-07-03 Thread Zac Medico
commit: 84aa6c743581222a3f4a8a855dbcb77a2774c5b6
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Jul  3 06:08:13 2016 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Jul  3 17:50:27 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=84aa6c74

eshowkw: migrate to PORTAGE_REPOSITORIES (bug 587856)

Since PORTDIR_OVERLAY is deprecated, migrate to PORTAGE_REPOSITORIES.

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

 pym/gentoolkit/eshowkw/__init__.py | 32 +++-
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index ded166d..42a3860 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -1,5 +1,5 @@
 #  vim:fileencoding=utf-8
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __package__ = 'gentoolkit.eshowkw'
@@ -122,10 +122,32 @@ def main(argv, indirect = False):
msg_err = 'No ebuilds at "%s"' % currdir
raise SystemExit(msg_err)
package= '%s/%s' % (os.path.basename(os.path.abspath('../')), 
os.path.basename(currdir))
-   ourtree = os.path.abspath('../../')
-   overlays = '%s %s' % (ports['PORTDIR_OVERLAY'], ourtree)
-   mysettings = portc(local_config=False, env={'PORTDIR_OVERLAY': 
overlays})
-   dbapi = portdbapi(mysettings=mysettings)
+   ourtree = os.path.realpath('../..')
+   ourstat = os.stat(ourtree)
+   ourstat = (ourstat.st_ino, ourstat.st_dev)
+   for repo in ports.repositories:
+   try:
+   repostat = os.stat(repo.location)
+   except OSError:
+   continue
+   if ourstat == (repostat.st_ino, repostat.st_dev):
+   dbapi = 
portdbapi(mysettings=portc(local_config=False))
+   break
+   else:
+   repos = {}
+   for repo in ports.repositories:
+   repos[repo.name] = repo.location
+
+   with open(os.path.join(ourtree, 'profiles', 
'repo_name'),
+   'rt') as f:
+   repo_name = f.readline().strip()
+
+   repos[repo_name] = ourtree
+   repos = ''.join('[{}]\nlocation={}\n'.format(k, v)
+   for k, v in repos.items())
+   mysettings = portc(local_config=False,
+   env={'PORTAGE_REPOSITORIES': repos})
+   dbapi = portdbapi(mysettings=mysettings)
# specify that we want just our nice tree we are in cwd
dbapi.porttrees = [ourtree]
process_display(package, keywords, dbapi)



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

2016-07-02 Thread Zac Medico
commit: a1262c6ff59120b4fd089275006148accfa078de
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Jul  3 04:21:37 2016 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Jul  3 04:23:21 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=a1262c6f

eshowkw: use portage.root for prefix support

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

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 1b9af0d..9c6538c 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -28,7 +28,7 @@ def load_profile_data(portdir=None, repo='gentoo'):
  {'x86': 'stable', 'mips': 'dev', ...}
"""
if portdir is None:
-   portdir = 
portage.db['/']['vartree'].settings.repositories[repo].location
+   portdir = 
portage.db[portage.root]['vartree'].settings.repositories[repo].location
 
arch_status = {}
 



[gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eshowkw/, pym/gentoolkit/deprecated/, pym/gentoolkit/, ...

2016-06-30 Thread Paul Varner
commit: 51f3cf18de49ca9dffc34053da53e62930be9fab
Author: Paul Varner  gentoo  org>
AuthorDate: Thu Jun 30 23:09:52 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Thu Jun 30 23:30:54 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=51f3cf18

Change open function to use UTF-8 encoding for content.

Uses io.open for Python 2 and built-in open for Python 3
All data from files is treated as Unicode and this should fix
most UnicodeDecodeErrors.

 pym/gentoolkit/deprecated/helpers.py  |  6 +-
 pym/gentoolkit/eclean/exclude.py  |  4 +++-
 pym/gentoolkit/enalyze/rebuild.py |  5 -
 pym/gentoolkit/equery/uses.py | 11 +++
 pym/gentoolkit/equery/which.py|  5 -
 pym/gentoolkit/eshowkw/keywords_header.py |  9 +++--
 pym/gentoolkit/glsa/__init__.py   |  5 -
 pym/gentoolkit/helpers.py |  3 ++-
 pym/gentoolkit/revdep_rebuild/analyse.py  |  6 +-
 pym/gentoolkit/revdep_rebuild/cache.py| 13 +
 pym/gentoolkit/revdep_rebuild/collect.py  |  8 ++--
 pym/gentoolkit/revdep_rebuild/settings.py |  4 +++-
 pym/gentoolkit/test/eclean/creator.py |  6 +-
 13 files changed, 64 insertions(+), 21 deletions(-)

diff --git a/pym/gentoolkit/deprecated/helpers.py 
b/pym/gentoolkit/deprecated/helpers.py
index 81fa45c..bb0fb7e 100644
--- a/pym/gentoolkit/deprecated/helpers.py
+++ b/pym/gentoolkit/deprecated/helpers.py
@@ -11,6 +11,10 @@ from __future__ import print_function
 
 import warnings
 
+import sys
+if sys.hexversion < 0x300:
+   from io import open
+
 import portage
 from portage import _encodings, _unicode_decode, _unicode_encode
 from gentoolkit import *
@@ -101,7 +105,7 @@ def find_world_packages(prefilter=None):
"""Returns a tuple of lists, first list is resolved world packages,
seond is unresolved package names."""
f = open(_unicode_encode(portage.root+portage.WORLD_FILE,
-   encoding=_encodings['fs']))
+   encoding=_encodings['fs']), encoding=_encodings['content'])
pkglist = f.readlines()
resolved = []
unresolved = []

diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py
index d19c1d1..513346d 100644
--- a/pym/gentoolkit/eclean/exclude.py
+++ b/pym/gentoolkit/eclean/exclude.py
@@ -9,6 +9,8 @@ from __future__ import print_function
 
 import os
 import sys
+if sys.hexversion < 0x300:
+   from io import open
 import re
 import portage
 from portage import _encodings, _unicode_decode, _unicode_encode
@@ -83,7 +85,7 @@ def parseExcludeFile(filepath, output):
output("Parsing Exclude file: " + filepath)
try:
file_ = open(_unicode_encode(filepath, 
-   encoding=_encodings['fs']), mode="r")
+   encoding=_encodings['fs']), mode="r", 
encoding=_encodings['content'])
except IOError:
raise ParseExcludeFileException("Could not open exclusion file: 
" +
filepath)

diff --git a/pym/gentoolkit/enalyze/rebuild.py 
b/pym/gentoolkit/enalyze/rebuild.py
index 11feb31..53fded4 100644
--- a/pym/gentoolkit/enalyze/rebuild.py
+++ b/pym/gentoolkit/enalyze/rebuild.py
@@ -15,6 +15,8 @@ from __future__ import print_function
 
 import os
 import sys
+if sys.hexversion < 0x300:
+   from io import open
 
 import gentoolkit
 from gentoolkit.module_base import ModuleBase
@@ -352,7 +354,8 @@ class Rebuild(ModuleBase):
"""
if  not self.options["quiet"]:
print('   - Saving file: %s' %filepath)
-   with open(_unicode_encode(filepath, encoding=_encodings['fs']), 
mode="w") as output:
+   with open(_unicode_encode(filepath, encoding=_encodings['fs']), 
mode="w",
+   encoding=_encodings['content']) as output:
output.write('\n'.join(data))
print("   - Done")
 

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 79f1118..a8f13dc 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -16,6 +16,9 @@ __docformat__ = 'epytext'
 
 import os
 import sys
+if sys.hexversion < 0x300:
+   from io import open
+
 from functools import partial
 from getopt import gnu_getopt, GetoptError
 from glob import glob
@@ -136,9 +139,9 @@ def get_global_useflags():
# Get global USE flag descriptions
try:
path = os.path.join(settings["PORTDIR"], 'profiles', 'use.desc')
-   with open(_unicode_encode(path, encoding=_encodings['fs'])) as 
open_file:
+   with open(_unicode_encode(path, encoding=_encodings['fs']),
+   encoding=_encodings['content']) as open_file:
for line in open_file:
-   line = _unicode_decode(line)
   

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

2016-04-06 Thread Paul Varner
commit: e4dda3ef193b109f30051f5a116158dfe23922bb
Author: Paul Varner  gentoo  org>
AuthorDate: Wed Apr  6 17:21:32 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Wed Apr  6 17:21:32 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e4dda3ef

eshowkw: Fix previous commit to not always turn on prefix

Mistakenly was checking highlight_arch instead of opts.arch to
see if any architectures were specified.  This had the effect of
always enabling the prefix architectures.

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

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index c00d7cb..ded166d 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -102,7 +102,7 @@ def main(argv, indirect = False):
porto.nocolor()
 
# Imply prefix if user specified any architectures (Bug 578496)
-   if len(highlight_arch) > 0:
+   if len(opts.arch) > 0:
prefix = True
 
keywords = keywords_header(prefix, highlight_arch, order)



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

2016-03-31 Thread Paul Varner
commit: 99bdbe3d832a3dabb7e9fb9c50cb9c4e1baf2f02
Author: Paul Varner  gentoo  org>
AuthorDate: Thu Mar 31 22:06:28 2016 +
Commit: Paul Varner  gentoo  org>
CommitDate: Thu Mar 31 22:06:28 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=99bdbe3d

eshowkw: Imply prefix when specifing an arch

This fixes bug 578496. When a user specifies and architecture, we should
just display it regardless of its prefix status.

 pym/gentoolkit/eshowkw/__init__.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index d46a773..c00d7cb 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -100,6 +100,11 @@ def main(argv, indirect = False):
if not color and not sys.stdout.isatty():
# disable colors
porto.nocolor()
+
+   # Imply prefix if user specified any architectures (Bug 578496)
+   if len(highlight_arch) > 0:
+   prefix = True
+
keywords = keywords_header(prefix, highlight_arch, order)
if len(package) > 0:
mysettings = portc(local_config=False)



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

2016-03-18 Thread Dirkjan Ochtman
commit: bde283951ef3c07a9476f4508ac5b57a5e634b64
Author: Dirkjan Ochtman  ochtman  nl>
AuthorDate: Thu Mar 17 21:39:23 2016 +
Commit: Dirkjan Ochtman  gentoo  org>
CommitDate: Thu Mar 17 21:39:23 2016 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=bde28395

Sort eshowkw headers by arch status first

 pym/gentoolkit/eshowkw/keywords_header.py | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 7bf71d0..bc5c0c5 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -92,9 +92,10 @@ class keywords_header:
return [x for x in ports.archlist()
if not x.startswith('~')]
 
-   @staticmethod
-   def __sortKeywords(keywords, prefix = False, required_keywords = []):
-   """Sort keywords with short archs first"""
+   def __sortKeywords(self, keywords, prefix = False, required_keywords = 
[]):
+   """Sort keywords: order by status (IMP, then DEV, then EXP, then
+   prefix), then by name."""
+
# user specified only some keywords to display
if len(required_keywords) != 0:
tmpkeywords = [k for k in keywords
@@ -103,15 +104,22 @@ class keywords_header:
if len(tmpkeywords) != 0:
keywords = tmpkeywords
 
-   normal = [k for k in keywords
-   if len(k.split('-')) == 1]
-   normal.sort()
-
+   normal = [k for k in keywords if len(k.split('-')) == 1]
if prefix:
longer = [k for k in keywords
if len(k.split('-')) != 1]
longer.sort()
normal.extend(longer)
+
+   lists = self.__IMPARCHS, self.__DEV_ARCHS, self.__EXP_ARCHS
+   levels = {}
+   for kw in normal:
+   for level, ls in enumerate(lists):
+   if kw in ls:
+   levels[kw] = level
+   break
+
+   normal.sort(key=lambda kw: (levels.get(kw, 99), kw))
return normal
 
def __readAdditionalFields(self):



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

2015-11-19 Thread Justin Lecher
commit: 239b0c9b6ea62189f6ce69f72a291a4f8c9fa463
Author: Justin Lecher  gentoo  org>
AuthorDate: Thu Nov 19 11:56:32 2015 +
Commit: Justin Lecher  gentoo  org>
CommitDate: Thu Nov 19 11:56:32 2015 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=239b0c9b

Get status of arch from profile

The stable, dev, exp status of the arches was hardcoded.
This change copies the code form ekeyword to read the status from profiles
directly.

Signed-off-by: Justin Lecher  gentoo.org>

 pym/gentoolkit/eshowkw/keywords_header.py | 76 +--
 1 file changed, 73 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py 
b/pym/gentoolkit/eshowkw/keywords_header.py
index 320406e..aaf1e8c 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -4,14 +4,84 @@
 
 __all__ = ['keywords_header']
 
+import portage
+import os
 from portage import settings as ports
 from portage.output import colorize
 from gentoolkit.eshowkw.display_pretty import colorize_string
 from gentoolkit.eshowkw.display_pretty import align_string
 
+# Copied from ekeyword
+def load_profile_data(portdir=None, repo='gentoo'):
+   """Load the list of known arches from the tree
+
+   Args:
+ portdir: The repository to load all data from (and ignore |repo|)
+ repo: Look up this repository by name to locate profile data
+
+   Returns:
+ A dict mapping the keyword to its preferred state:
+ {'x86': 'stable', 'mips': 'dev', ...}
+   """
+   if portdir is None:
+   portdir = 
portage.db['/']['vartree'].settings.repositories[repo].location
+
+   arch_status = {}
+
+   try:
+   arch_list = os.path.join(portdir, 'profiles', 'arch.list')
+   with open(arch_list) as f:
+   for line in f:
+   line = line.split('#', 1)[0].strip()
+   if line:
+   arch_status[line] = None
+   except IOError:
+   pass
+
+   try:
+   profile_status = {
+   'stable': 0,
+   'dev': 1,
+   'exp': 2,
+   None: 3,
+   }
+   profiles_list = os.path.join(portdir, 'profiles', 
'profiles.desc')
+   with open(profiles_list) as f:
+   for line in f:
+   line = line.split('#', 1)[0].split()
+   if line:
+   arch, _profile, status = line
+   arch_status.setdefault(arch, status)
+   curr_status = 
profile_status[arch_status[arch]]
+   new_status = profile_status[status]
+   if new_status < curr_status:
+   arch_status[arch] = status
+   except IOError:
+   pass
+
+   if arch_status:
+   arch_status['all'] = None
+   else:
+   warning('could not read profile files: %s' % arch_list)
+   warning('will not be able to verify args are correct')
+
+   return arch_status
+
+def gen_arch_list(status):
+   _arch_status = load_profile_data()
+   if status == "stable":
+   return [arch for arch in _arch_status if _arch_status[arch] == 
"stable"]
+   elif status == "dev":
+   return [arch for arch in _arch_status if _arch_status[arch] == 
"dev"]
+   elif status == "exp":
+   return [arch for arch in _arch_status if _arch_status[arch] == 
"exp"]
+   else:
+   raise TypeError
+
 class keywords_header:
-   __IMPARCHS = [ 'arm', 'amd64', 'x86' ]
-   __UNSTABLE_ARCHS = [ 'arm64', 'm68k', 'mips', 's390', 'sh' ]
+   __IMPARCHS = gen_arch_list("stable")
+   __DEV_ARCHS = gen_arch_list("dev")
+   __EXP_ARCHS = gen_arch_list("exp")
__ADDITIONAL_FIELDS = [ 'eapi', 'unused', 'slot' ]
__EXTRA_FIELDS = [ 'repo' ]
 
@@ -61,7 +131,7 @@ class keywords_header:
keyword = '%'.join(list(keyword))
if tmp2 in self.__IMPARCHS:
tmp.append(colorize_string('darkyellow', 
keyword))
-   elif tmp2 in self.__UNSTABLE_ARCHS:
+   elif tmp2 in self.__EXP_ARCHS:
tmp.append(colorize_string('darkgray', keyword))
else:
tmp.append(keyword)



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

2015-11-17 Thread Justin Lecher
commit: 95b5655ae01c0185a9539d1921509277fa778102
Author: Denis Romanchuk  gmail  com>
AuthorDate: Mon Nov 16 04:01:21 2015 +
Commit: Justin Lecher  gentoo  org>
CommitDate: Tue Nov 17 10:18:17 2015 +
URL:https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=95b5655a

Add eapi column to the eshowkw

Signed-off-by: Justin Lecher  gentoo.org>

 pym/gentoolkit/eshowkw/__init__.py |  5 +---
 pym/gentoolkit/eshowkw/keywords_content.py | 42 ++
 pym/gentoolkit/eshowkw/keywords_header.py  |  2 +-
 3 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/__init__.py 
b/pym/gentoolkit/eshowkw/__init__.py
index a20dac9..d46a773 100644
--- a/pym/gentoolkit/eshowkw/__init__.py
+++ b/pym/gentoolkit/eshowkw/__init__.py
@@ -72,7 +72,7 @@ def process_args(argv):
parser.add_argument('-P', '--prefix', action='store_true', 
default=False,
help='Display prefix keywords in output.')
parser.add_argument('-S', '--ignore-slot', action='store_true', 
default=False,
-   help='Treat slots as irelevant during detection of redundant 
pacakges.')
+   help='Treat slots as irelevant during detection of redundant 
packages.')
 
return parser.parse_args(args=argv)
 
@@ -83,9 +83,6 @@ def main(argv, indirect = False):
opts = process_args(argv)
ignore_slots = opts.ignore_slot
use_overlays = opts.overlays
-   # user can do both --arch=a,b,c or --arch a b c
-   if len(opts.arch) > 1:
-   opts.arch = ','.join(opts.arch)
highlight_arch = ''.join(opts.arch).split(',')
bold = opts.bold
order = opts.align

diff --git a/pym/gentoolkit/eshowkw/keywords_content.py 
b/pym/gentoolkit/eshowkw/keywords_content.py
index 2e6c0fa..b6ad118 100644
--- a/pym/gentoolkit/eshowkw/keywords_content.py
+++ b/pym/gentoolkit/eshowkw/keywords_content.py
@@ -164,7 +164,7 @@ class keywords_content:
def __packages_sort(package_content):
"""
Sort packages queried based on version and slot
-   %% pn , repo, slot, keywords
+   %% pn , repo, slot, eapi, keywords
"""
from operator import itemgetter
 
@@ -208,8 +208,8 @@ class keywords_content:
# version is not allowed by 
portage or unset
continue
# obtain related data from metadata and 
append to the pkg list
-   keywords, slot = 
self.__getMetadata(pdb, mysplit[0]+'/'+pf, oroot)
-   mypkgs.append([mysplit[0]+'/'+pf, 
oroot, slot, keywords])
+   keywords, slot, eapi = 
self.__getMetadata(pdb, mysplit[0]+'/'+pf, oroot)
+   mypkgs.append([mysplit[0]+'/'+pf, 
oroot, slot, eapi, keywords])
 
self.__packages_sort(mypkgs)
return mypkgs
@@ -226,7 +226,7 @@ class keywords_content:
def __getMetadata(pdb, package, repo):
"""Obtain all required metadata from portage auxdb"""
try:
-   metadata = pdb.aux_get(package, ['KEYWORDS', 'SLOT'], 
repo)
+   metadata = pdb.aux_get(package, ['KEYWORDS', 'SLOT', 
'EAPI'], repo)
except KeyError:
# portage prints out more verbose error for us if we 
were lucky
raise SystemExit('Failed to obtain metadata')
@@ -303,24 +303,42 @@ class keywords_content:
return tmp
 
@staticmethod
-   def __prepareContentResult(versions, keywords, redundant, slots, 
slot_length, repos, linesep):
+   def __formatEapis(eapis, repos, repos_configs, length):
+   """Align eapis items properly"""
+   # % are used as separators for further split so we wont loose 
spaces and coloring
+   tmp = []
+   for eapi, repo in zip(eapis, repos):
+   tmp_eapi = eapi
+   eapi = align_string(eapi, 'left', length)
+   eapi = '%'.join(list(eapi))
+   if repos_configs[repo].eapi_is_banned(tmp_eapi):
+   eapi = colorize_string('red', eapi)
+   elif repos_configs[repo].eapi_is_deprecated(tmp_eapi):
+   eapi = colorize_string('yellow', eapi)
+   else:
+   eapi = colorize_string('green', eapi)
+   tmp.append(eapi)
+   return tmp
+
+   @staticmethod
+   def __prepareContentResult(versions, keywords, eapi, redundant, slots, 
slot_length, repos, linesep):
"""Parse version fields into one list with proper separators"""
content = []