From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-870640-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 62C0759CA3 for <garchives@archives.gentoo.org>; Thu, 17 Mar 2016 21:39:37 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3AC64E080B; Thu, 17 Mar 2016 21:39:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D8C94E080B for <gentoo-commits@lists.gentoo.org>; Thu, 17 Mar 2016 21:39:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CD3FF340BD7 for <gentoo-commits@lists.gentoo.org>; Thu, 17 Mar 2016 21:39:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4790A85B for <gentoo-commits@lists.gentoo.org>; Thu, 17 Mar 2016 21:39:28 +0000 (UTC) From: "Dirkjan Ochtman" <djc@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Dirkjan Ochtman" <djc@gentoo.org> Message-ID: <1458250763.bde283951ef3c07a9476f4508ac5b57a5e634b64.djc@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eshowkw/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/eshowkw/keywords_header.py X-VCS-Directories: pym/gentoolkit/eshowkw/ X-VCS-Committer: djc X-VCS-Committer-Name: Dirkjan Ochtman X-VCS-Revision: bde283951ef3c07a9476f4508ac5b57a5e634b64 X-VCS-Branch: master Date: Thu, 17 Mar 2016 21:39:28 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: bdb9c941-be28-44dc-8644-5b4575497580 X-Archives-Hash: f2930554cdc916ccda057bc74ecd60dd commit: bde283951ef3c07a9476f4508ac5b57a5e634b64 Author: Dirkjan Ochtman <dirkjan <AT> ochtman <DOT> nl> AuthorDate: Thu Mar 17 21:39:23 2016 +0000 Commit: Dirkjan Ochtman <djc <AT> gentoo <DOT> org> CommitDate: Thu Mar 17 21:39:23 2016 +0000 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):