[libpeas] Support Python plugins that define __all__
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Support Python plugins that define __all__
- Date: Wed, 4 Feb 2015 14:34:16 +0000 (UTC)
commit 557abb55ee4429ebe6f48aed5a67950c0374b043
Author: Garrett Regier <garrettregier gmail com>
Date: Tue Jan 20 17:25:15 2015 -0800
Support Python plugins that define __all__
Instead of going through every local in the
plugin just check those in __all__, if defined.
https://bugzilla.gnome.org/show_bug.cgi?id=741802
loaders/python/peas-python-internal.py | 8 +++++++-
.../plugins/extension-python/extension-py.py.in | 3 +++
2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/loaders/python/peas-python-internal.py b/loaders/python/peas-python-internal.py
index d14b4d8..f05b840 100644
--- a/loaders/python/peas-python-internal.py
+++ b/loaders/python/peas-python-internal.py
@@ -131,7 +131,13 @@ class Hooks(object):
except KeyError:
pass
- for key in module.__dict__:
+ try:
+ keys = module.__all__
+
+ except AttributeError:
+ keys = module.__dict__
+
+ for key in keys:
value = getattr(module, key)
try:
diff --git a/tests/libpeas/plugins/extension-python/extension-py.py.in
b/tests/libpeas/plugins/extension-python/extension-py.py.in
index 063ac56..5a10e82 100644
--- a/tests/libpeas/plugins/extension-python/extension-py.py.in
+++ b/tests/libpeas/plugins/extension-python/extension-py.py.in
@@ -6,6 +6,9 @@ import threading
from gi.repository import GObject, Introspection, Peas
+__all__ = [ 'ExtensionPythonPlugin' ]
+
+
class ExtensionPythonPlugin(GObject.Object, Peas.Activatable,
Introspection.Base, Introspection.Callable,
Introspection.HasPrerequisite):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]