[PATCH 2/2] Honor modules' __all__ when doing collect
Vratislav Podzimek
vpodzime at redhat.com
Tue Feb 12 15:05:35 UTC 2013
From: Martin Sivak <msivak at redhat.com>
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/ui/common.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index b783f5e..c94861e 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -541,7 +541,15 @@ def collect(module_pattern, path, pred):
p = lambda obj: inspect.isclass(obj) and pred(obj)
- for (name, val) in inspect.getmembers(module, p):
+ # if __all__ is defined in the module, use it
+ if not hasattr(module, "__all__"):
+ members = inspect.getmembers(module, p)
+ else:
+ members = [(name, getattr(module, name))
+ for name in module.__all__
+ if p(getattr(module, name))]
+
+ for (name, val) in members:
retval.append(val)
return retval
--
1.7.11.7
More information about the anaconda-patches
mailing list