Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/
Date: Mon, 25 Apr 2016 15:32:47
Message-Id: 1461598133.edd6f6cd73839dad09ce7c65c09ac38c30e6b5eb.dolsen@gentoo
1 commit: edd6f6cd73839dad09ce7c65c09ac38c30e6b5eb
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 16 23:29:20 2016 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Mon Apr 25 15:28:53 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=edd6f6cd
7
8 repoman: Limit the kwargs passed to the module's __init__()
9
10 This has the benefit of forcing the module to declare what data it requires.
11 Rather than possibly silently fail.
12
13 pym/repoman/scanner.py | 17 ++++++++++++++---
14 1 file changed, 14 insertions(+), 3 deletions(-)
15
16 diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
17 index e9a8e20..5ac519e 100644
18 --- a/pym/repoman/scanner.py
19 +++ b/pym/repoman/scanner.py
20 @@ -202,7 +202,18 @@ class Scanner(object):
21 'fetches', 'pkgmetadata']:
22 mod_class = MODULE_CONTROLLER.get_class(mod)
23 logging.debug("Initializing class name: %s", mod_class.__name__)
24 - self.modules[mod_class.__name__] = mod_class(**self.kwargs)
25 + self.modules[mod_class.__name__] = mod_class(**self.set_kwargs(mod))
26 +
27 + def set_kwargs(self, mod):
28 + '''Creates a limited set of kwargs to pass to the module's __init__()
29 +
30 + @param mod: module name string
31 + @returns: dictionary
32 + '''
33 + kwargs = {}
34 + for key in MODULE_CONTROLLER.modules[mod]['mod_kwargs']:
35 + kwargs[key] = self.kwargs[key]
36 + return kwargs
37
38 def scan_pkgs(self, can_force):
39 for xpkg in self.effective_scanlist:
40 @@ -295,7 +306,7 @@ class Scanner(object):
41 if mod[0]:
42 mod_class = MODULE_CONTROLLER.get_class(mod[0])
43 logging.debug("Initializing class name: %s", mod_class.__name__)
44 - self.modules[mod[1]] = mod_class(**self.kwargs)
45 + self.modules[mod[1]] = mod_class(**self.set_kwargs(mod))
46 logging.debug("scan_ebuilds: module: %s", mod[1])
47 do_it, functions = self.modules[mod[1]].runInEbuilds
48 logging.debug("do_it: %s, functions: %s", do_it, [x.__name__ for x in functions])
49 @@ -329,7 +340,7 @@ class Scanner(object):
50 if mod[0]:
51 mod_class = MODULE_CONTROLLER.get_class(mod[0])
52 logging.debug("Initializing class name: %s", mod_class.__name__)
53 - self.modules[mod[1]] = mod_class(**self.kwargs)
54 + self.modules[mod[1]] = mod_class(**self.set_kwargs(mod))
55 logging.debug("scan_ebuilds final checks: module: %s", mod[1])
56 do_it, functions = self.modules[mod[1]].runInFinal
57 logging.debug("do_it: %s, functions: %s", do_it, [x.__name__ for x in functions])