From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 228C4139695 for ; Mon, 10 Jul 2017 17:52:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6A36A2740D5; Mon, 10 Jul 2017 17:52:35 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 4176D27415B for ; Mon, 10 Jul 2017 17:52:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3E0BE341B6B for ; Mon, 10 Jul 2017 17:52:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4C48774AC for ; Mon, 10 Jul 2017 17:52:32 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1499709019.a9da39a81f0469ab7e2086b3225c45ad5def25a1.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/module.py X-VCS-Directories: pym/portage/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: a9da39a81f0469ab7e2086b3225c45ad5def25a1 X-VCS-Branch: repoman Date: Mon, 10 Jul 2017 17:52:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 28821f6c-73dc-4934-920c-2b4b3e976282 X-Archives-Hash: 7456aa39f7e98715c46e1799dce07aef commit: a9da39a81f0469ab7e2086b3225c45ad5def25a1 Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 10 17:29:05 2017 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Mon Jul 10 17:50:19 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a9da39a8 portage/module.py: Add a generic get_spec() This new function gets any arbitrary spec value. The other get_* functions could be optimized to return the get_spec result instead. This would reduce code duplication. pym/portage/module.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pym/portage/module.py b/pym/portage/module.py index f9828a518..00f322387 100644 --- a/pym/portage/module.py +++ b/pym/portage/module.py @@ -205,3 +205,18 @@ class Modules(object): raise InvalidModuleName( "Module name '%s' was invalid or not found" % modname) return desc + + def get_spec(self, modname, var): + """Retrieves the module class exported spec variable + + @type modname: string + @param modname: the module class name + @type dictionary + @return: the modules class exported options descriptions + """ + if modname and modname in self.module_names: + value = self._modules[modname].get(var, None) + else: + raise InvalidModuleName( + "Module name '%s' was invalid or not found" % modname) + return value