From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id AC8E259CB3 for ; Sun, 17 Apr 2016 15:42:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 25D2421C042; Sun, 17 Apr 2016 15:42:45 +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 7FFD721C042 for ; Sun, 17 Apr 2016 15:42:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 A90B134098F for ; Sun, 17 Apr 2016 15:42:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 351C81FC for ; Sun, 17 Apr 2016 15:42:39 +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: <1460849911.890f4f45fd9bdad86ce0aa5abb2afc8ef20acf48.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/scanner.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 890f4f45fd9bdad86ce0aa5abb2afc8ef20acf48 X-VCS-Branch: repoman Date: Sun, 17 Apr 2016 15:42:39 +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: f1656e17-a4a8-4812-b177-062e8ae079ce X-Archives-Hash: 03dd46c9b1c52b5ad894f0f27349081e commit: 890f4f45fd9bdad86ce0aa5abb2afc8ef20acf48 Author: Brian Dolbec gentoo org> AuthorDate: Sat Apr 16 23:29:20 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat Apr 16 23:38:31 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=890f4f45 repoman: Limit the kwargs passed to the module's __init__() This has the benefit of forcing the module to declare what data it requires. Rather than possibly silently fail. pym/repoman/scanner.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py index e9a8e20..d01277e 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -202,7 +202,18 @@ class Scanner(object): 'fetches', 'pkgmetadata']: mod_class = MODULE_CONTROLLER.get_class(mod) logging.debug("Initializing class name: %s", mod_class.__name__) - self.modules[mod_class.__name__] = mod_class(**self.kwargs) + self.modules[mod_class.__name__] = mod_class(**self.set_kwargs(mod)) + + def set_kwargs(self, mod): + '''Creates a limited set or kwargs to pass to the module's __init__() + + @param mod: module name string + @returns: dictionary + ''' + kwargs = {} + for key in MODULE_CONTROLLER.modules[mod]['mod_kwargs']: + kwargs[key] = self.kwargs[key] + return kwargs def scan_pkgs(self, can_force): for xpkg in self.effective_scanlist: @@ -295,7 +306,7 @@ class Scanner(object): if mod[0]: mod_class = MODULE_CONTROLLER.get_class(mod[0]) logging.debug("Initializing class name: %s", mod_class.__name__) - self.modules[mod[1]] = mod_class(**self.kwargs) + self.modules[mod[1]] = mod_class(**self.set_kwargs(mod)) logging.debug("scan_ebuilds: module: %s", mod[1]) do_it, functions = self.modules[mod[1]].runInEbuilds logging.debug("do_it: %s, functions: %s", do_it, [x.__name__ for x in functions]) @@ -329,7 +340,7 @@ class Scanner(object): if mod[0]: mod_class = MODULE_CONTROLLER.get_class(mod[0]) logging.debug("Initializing class name: %s", mod_class.__name__) - self.modules[mod[1]] = mod_class(**self.kwargs) + self.modules[mod[1]] = mod_class(**self.set_kwargs(mod)) logging.debug("scan_ebuilds final checks: module: %s", mod[1]) do_it, functions = self.modules[mod[1]].runInFinal logging.debug("do_it: %s, functions: %s", do_it, [x.__name__ for x in functions])