[kupfer] Allow plugins installed in .zip packages
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] Allow plugins installed in .zip packages
- Date: Mon, 8 Feb 2010 21:14:38 +0000 (UTC)
commit 1882035cf381b4d4f0de865894964e24016f6b0b
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Feb 8 21:15:53 2010 +0100
Allow plugins installed in .zip packages
We find .zip files in all plugin directories and add them to Python's
path. This means that you can take a plugin python package (folder
with __init__.py inside, and icons and what you want), compress it as
a .zip file pluginname.zip and add it in ~/.local/share/kupfer/plugins
kupfer/plugin/__init__.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/__init__.py b/kupfer/plugin/__init__.py
index a93fbcb..da24234 100644
--- a/kupfer/plugin/__init__.py
+++ b/kupfer/plugin/__init__.py
@@ -1,3 +1,19 @@
+import os
+
from kupfer import config
+from kupfer import pretty
+# Add plugins in data directories
__path__.extend(config.get_data_dirs("plugins"))
+
+# Add .zip files in plugins directories
+for directory in list(__path__):
+ try:
+ filenames = os.listdir(directory)
+ except OSError, err:
+ pretty.print_error(__name__, err)
+ continue
+ zipnames = [f for f in filenames if f.endswith(".zip")]
+ if zipnames:
+ pretty.print_debug(__name__, "Adding", directory, zipnames)
+ __path__.extend(os.path.join(directory, z) for z in zipnames)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]