[gedit-plugins] Support modules with underscores
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Support modules with underscores
- Date: Thu, 16 Aug 2012 10:28:10 +0000 (UTC)
commit 45900a842fccdbdaeaf176404ea96c44b19b50a7
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Thu Aug 16 12:28:04 2012 +0200
Support modules with underscores
plugins/commander/commander/commands/method.py | 1 +
plugins/commander/commander/commands/module.py | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/plugins/commander/commander/commands/method.py b/plugins/commander/commander/commands/method.py
index 38456b4..15c9e4e 100644
--- a/plugins/commander/commander/commands/method.py
+++ b/plugins/commander/commander/commands/method.py
@@ -28,6 +28,7 @@ import commander.utils as utils
class Method:
def __init__(self, method, name, parent):
self.method = method
+ self.real_name = name
self.name = name.replace('_', '-')
self.parent = parent
self._func_props = None
diff --git a/plugins/commander/commander/commands/module.py b/plugins/commander/commander/commands/module.py
index dfc7f53..5277138 100644
--- a/plugins/commander/commander/commands/module.py
+++ b/plugins/commander/commander/commands/module.py
@@ -119,7 +119,7 @@ class Module(method.Method):
if not self.unload():
return
- if self.name in sys.modules:
+ if self.real_name in sys.modules:
raise Exception('Module already exists...')
oldpath = list(sys.path)
@@ -128,7 +128,7 @@ class Module(method.Method):
sys.path.insert(0, self._dirname)
self._rollback.monitor()
- self.mod = __import__(self.name, globals(), locals(), [], 0)
+ self.mod = __import__(self.real_name, globals(), locals(), [], 0)
self._rollback.cancel()
if not utils.is_commander_module(self.mod):
@@ -144,8 +144,8 @@ class Module(method.Method):
sys.path = oldpath
self._rollback.uninstall()
- if self.name in sys.modules:
- del sys.modules[self.name]
+ if self.real_name in sys.modules:
+ del sys.modules[self.real_name]
raise
sys.path = oldpath
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]