Skip to content

Commit 4f327f1

Browse files
author
borysiasty
committed
new utils.showPluginHelp() method - patch #2562 by ccrook applied
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13097 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1874c21 commit 4f327f1

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

python/utils.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
"""
66

7-
from PyQt4.QtCore import QCoreApplication
7+
from PyQt4.QtCore import QCoreApplication,QLocale
88
from qgis.core import QGis
99
import sys
1010
import traceback
@@ -176,7 +176,9 @@ def canUninstallPlugin(packageName):
176176
return True
177177
return bool(metadata.canBeUninstalled())
178178
except:
179-
return False
179+
msg = "Error calling "+packageName+".canBeUninstalled"
180+
showException(sys.exc_type, sys.exc_value, sys.exc_traceback, msg)
181+
return True
180182

181183

182184
def unloadPlugin(packageName):
@@ -240,6 +242,28 @@ def reloadPlugin(packageName):
240242
startPlugin(packageName)
241243

242244

245+
def showPluginHelp(packageName=None,filename="index",section=""):
246+
try:
247+
source = ""
248+
if packageName is None:
249+
import inspect
250+
source = inspect.currentframe().f_back.f_code.co_filename
251+
else:
252+
source = sys.modules[packageName].__file__
253+
except:
254+
return
255+
path = os.path.dirname(source)
256+
locale = str(QLocale().name()).split("_")[0]
257+
helpfile = os.path.join(path,filename+"-"+locale+".html")
258+
if not os.path.exists(helpfile):
259+
helpfile = os.path.join(path,filename+".html")
260+
if os.path.exists(helpfile):
261+
url = "file://"+helpfile
262+
if section != "":
263+
url = url + "#" + section
264+
iface.openURL(url,False)
265+
266+
243267
#######################
244268
# IMPORT wrapper
245269

0 commit comments

Comments
 (0)