[gedit-plugins] Allow calling modules in commander.modules
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Allow calling modules in commander.modules
- Date: Thu, 16 Aug 2012 10:51:24 +0000 (UTC)
commit feda97d808d1f936dbd53ac6803512aeb330c669
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Thu Aug 16 12:51:17 2012 +0200
Allow calling modules in commander.modules
plugins/commander/commander/commands/Makefile.am | 1 +
plugins/commander/commander/commands/__init__.py | 3 +-
plugins/commander/commander/commands/metamodule.py | 52 ++++++++++++++++++++
3 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/plugins/commander/commander/commands/Makefile.am b/plugins/commander/commander/commands/Makefile.am
index dd8830a..3262db4 100644
--- a/plugins/commander/commander/commands/Makefile.am
+++ b/plugins/commander/commander/commands/Makefile.am
@@ -9,6 +9,7 @@ plugin_PYTHON = \
__init__.py \
method.py \
module.py \
+ metamodule.py \
result.py \
rollbackimporter.py
diff --git a/plugins/commander/commander/commands/__init__.py b/plugins/commander/commander/commands/__init__.py
index feeab1c..c66cc1c 100644
--- a/plugins/commander/commander/commands/__init__.py
+++ b/plugins/commander/commander/commands/__init__.py
@@ -32,6 +32,7 @@ import module
import method
import result
import exceptions
+import metamodule
from accel_group import AccelGroup
from accel_group import Accelerator
@@ -415,7 +416,7 @@ class Commands(Singleton):
for r in mod.roots():
bisect.insort(self._modules, r)
- commander.modules.__dict__[mod.name] = mod.mod
+ commander.modules.__dict__[mod.name] = metamodule.MetaModule(mod.mod)
if self._accel_group:
self.scan_accelerators([mod])
diff --git a/plugins/commander/commander/commands/metamodule.py b/plugins/commander/commander/commands/metamodule.py
new file mode 100644
index 0000000..afbab4f
--- /dev/null
+++ b/plugins/commander/commander/commands/metamodule.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+#
+# metamodule.py
+#
+# Copyright (C) 2012 - Jesse van den Kieboom
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307, USA.
+class MetaModule(object):
+ def __init__(self, mod):
+ object.__setattr__(self, '_mod', mod)
+
+ def __getattribute__(self, name):
+ return getattr(object.__getattribute__(self, "_mod"), name)
+
+ def __delattr__(self, name):
+ delattr(object.__getattribute__(self, "_mod"), name)
+
+ def __setattr__(self, name, value):
+ setattr(object.__getattribute__(self, "_mod"), name, value)
+
+ def __getitem__(self, item):
+ return object.__getattribute__(self, "_mod")[item]
+
+ def __setitem__(self, item, value):
+ object.__getattribute__(self, "_mod")[item] = value
+
+ def __delitem__(self, item):
+ del object.__getattribute__(self, "_mod")[item]
+
+ def __iter__(self):
+ return iter(object.__getattribute__(self, "_mod"))
+
+ def __contains__(self, item):
+ return item in object.__getattribute__(self, "_mod")
+
+ def __call__(self, *args, **kw):
+ object.__getattribute__(self, "_mod").__default__(*args, **kw)
+
+# vi:ts=4:et
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]