diff options
author | Mason Larobina <mason.larobina@gmail.com> | 2009-09-11 02:59:07 +0800 |
---|---|---|
committer | Mason Larobina <mason.larobina@gmail.com> | 2009-09-11 02:59:07 +0800 |
commit | a4c2f07ca5dad85f8f965dd1462703c5a3f4e1b8 (patch) | |
tree | 2c682527818136a019dfc551fb6225f24c79df0d /examples/data/uzbl/scripts | |
parent | 09cb17496ce37b96898eb6a4246aa9e6603222a8 (diff) |
Removed "def export_name(..):" in favour of "__export__ = ['name',]"
Diffstat (limited to 'examples/data/uzbl/scripts')
-rwxr-xr-x | examples/data/uzbl/scripts/event_manager.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/data/uzbl/scripts/event_manager.py b/examples/data/uzbl/scripts/event_manager.py index e131306..927b515 100755 --- a/examples/data/uzbl/scripts/event_manager.py +++ b/examples/data/uzbl/scripts/event_manager.py @@ -375,17 +375,21 @@ class UzblInstance(object): # Map all plugin exports for (name, plugin) in self.plugins.items(): - for attr in dir(plugin): - if not attr.startswith('export_') or attr == 'export_': - continue + if not hasattr(plugin, '__export__'): + continue + + for export in plugin.__export__: + if export in self._exports: + orig = self._exports[export] + raise KeyError("already exported attribute: %r" % export) - obj = getattr(plugin, attr) + obj = getattr(plugin, export) if iscallable(obj): # Wrap the function in the CallPrepender object to make # the exposed functions act like instance methods. obj = CallPrepender(self, obj).call - self._exports[attr[7:]] = obj + self._exports[export] = obj echo("exposed attribute(s): %s" % ', '.join(self._exports.keys())) |