[QGIS Commit] r13097 - trunk/qgis/python

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Mar 20 05:23:38 EDT 2010


Author: borysiasty
Date: 2010-03-20 05:23:38 -0400 (Sat, 20 Mar 2010)
New Revision: 13097

Modified:
   trunk/qgis/python/utils.py
Log:
new utils.showPluginHelp() method - patch #2562 by ccrook applied

Modified: trunk/qgis/python/utils.py
===================================================================
--- trunk/qgis/python/utils.py	2010-03-20 09:22:07 UTC (rev 13096)
+++ trunk/qgis/python/utils.py	2010-03-20 09:23:38 UTC (rev 13097)
@@ -4,7 +4,7 @@
 
 """
 
-from PyQt4.QtCore import QCoreApplication
+from PyQt4.QtCore import QCoreApplication,QLocale
 from qgis.core import QGis
 import sys
 import traceback
@@ -176,7 +176,9 @@
       return True
     return bool(metadata.canBeUninstalled())
   except:
-    return False
+    msg = "Error calling "+packageName+".canBeUninstalled"
+    showException(sys.exc_type, sys.exc_value, sys.exc_traceback, msg)
+    return True
 
 
 def unloadPlugin(packageName):
@@ -240,6 +242,28 @@
   startPlugin(packageName)
 
 
+def showPluginHelp(packageName=None,filename="index",section=""):
+  try:
+    source = ""
+    if packageName is None:
+       import inspect
+       source = inspect.currentframe().f_back.f_code.co_filename
+    else:
+       source = sys.modules[packageName].__file__
+  except:
+    return
+  path = os.path.dirname(source)
+  locale = str(QLocale().name()).split("_")[0]
+  helpfile = os.path.join(path,filename+"-"+locale+".html")
+  if not os.path.exists(helpfile):
+    helpfile = os.path.join(path,filename+".html")
+  if os.path.exists(helpfile):
+    url = "file://"+helpfile
+    if section != "":
+        url = url + "#" + section
+    iface.openURL(url,False)
+
+
 #######################
 # IMPORT wrapper
 



More information about the QGIS-commit mailing list