[QGIS Commit] r13236 - trunk/qgis/python
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Apr 4 06:30:40 EDT 2010
Author: wonder
Date: 2010-04-04 06:30:40 -0400 (Sun, 04 Apr 2010)
New Revision: 13236
Modified:
trunk/qgis/python/utils.py
Log:
[FEATURE] support for custom plugin directories using QGIS_PLUGINPATH environment variables.
More paths can be passed, separated by semicolon. Patch from Chris Crook (#2608), slightly modified.
Modified: trunk/qgis/python/utils.py
===================================================================
--- trunk/qgis/python/utils.py 2010-04-04 00:57:06 UTC (rev 13235)
+++ trunk/qgis/python/utils.py 2010-04-04 10:30:40 UTC (rev 13236)
@@ -71,24 +71,31 @@
def findPlugins(path):
plugins = []
- for plugin in glob.glob(path + "/plugins/*"):
- if os.path.isdir(plugin):
+ for plugin in glob.glob(path + "/*"):
+ if os.path.isdir(plugin) and os.path.exists(os.path.join(plugin, '__init__.py')):
plugins.append( os.path.basename(plugin) )
-
return plugins
def updateAvailablePlugins():
from qgis.core import QgsApplication
- pythonPath = unicode(QgsApplication.pkgDataPath()) + "/python"
- homePythonPath = unicode(QgsApplication.qgisSettingsDirPath()) + "/python"
+ plugindirs = [
+ unicode(QgsApplication.pkgDataPath()) + "/python/plugins",
+ unicode(QgsApplication.qgisSettingsDirPath()) + "/python/plugins"
+ ]
+ env = os.environ.get("QGIS_PLUGINPATH")
+ if env:
+ plugindirs.extend(env.split(";"))
- plugins = findPlugins( pythonPath )
- homePlugins = findPlugins( homePythonPath )
-
# merge the lists
- for p in homePlugins:
- if p not in plugins:
- plugins.append(p)
+ plugins = []
+ for pluginpath in plugindirs:
+ newplugins = findPlugins(pluginpath)
+ if len(newplugins) > 0:
+ if pluginpath not in sys.path:
+ sys.path.append(pluginpath)
+ for p in newplugins:
+ if p not in plugins:
+ plugins.append(p)
global available_plugins
available_plugins = plugins
More information about the QGIS-commit
mailing list