[kupfer] plugin.kupfer_plugins: Show source even for plugins inside zips



commit f7f4e0949fad9bb2b714fb7a6f1550f7b13dac94
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Nov 5 19:30:15 2009 +0100

    plugin.kupfer_plugins: Show source even for plugins inside zips

 kupfer/plugin/kupfer_plugins.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/plugin/kupfer_plugins.py b/kupfer/plugin/kupfer_plugins.py
index 6ec5caa..2627558 100644
--- a/kupfer/plugin/kupfer_plugins.py
+++ b/kupfer/plugin/kupfer_plugins.py
@@ -1,6 +1,6 @@
 import os
 
-from kupfer.objects import Action, Source, Leaf, FileLeaf
+from kupfer.objects import Action, Source, Leaf, FileLeaf, TextLeaf
 from kupfer import icons, plugin_support
 
 # Since this is a core plugin we break some rules
@@ -49,6 +49,14 @@ class ShowSource (Action):
 		root, ext = os.path.splitext(filename)
 		if ext.lower() == ".pyc" and os.path.exists(root + ".py"):
 			return FileLeaf(root + ".py")
+
+		if not os.path.exists(filename):
+			# handle modules in zip or eggs
+			import pkgutil
+			pfull = "kupfer.plugin." + plugin_id
+			loader = pkgutil.get_loader(pfull)
+			if loader:
+				return TextLeaf(loader.get_source(pfull))
 		return FileLeaf(filename)
 
 	def get_description(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]