Skip to content

Commit a53a6e4

Browse files
Médéric RIBREUXalexbruy
Médéric RIBREUX
authored andcommittedMar 8, 2016
[Processing] Use local GRASS7 help files if they exist. Fixes #7745
1 parent f55ec08 commit a53a6e4

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed
 

‎python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import uuid
3131
import importlib
3232

33-
from PyQt4.QtCore import QCoreApplication
33+
from PyQt4.QtCore import QCoreApplication, QUrl
3434
from PyQt4.QtGui import QIcon
3535

3636
from qgis.core import QgsRasterLayer
@@ -87,6 +87,33 @@ def getIcon(self):
8787
return QIcon(os.path.join(pluginPath, 'images', 'grass.png'))
8888

8989
def help(self):
90+
localDoc = None
91+
html = self.grass7Name + '.html'
92+
if system.isWindows():
93+
# For MS-Windows, use the configured GRASS7 path
94+
localPath = os.path.join(Grass7Utils.grassPath(), 'docs/html', html)
95+
if os.path.exists(localPath):
96+
localDoc = os.path.abspath(localPath)
97+
elif system.isMac():
98+
# For MacOSX official package
99+
localPath = os.path.join('/Applications/GRASS-7.0.app/Contents/MacOS/docs/html', html)
100+
if os.path.exists(localPath):
101+
localDoc = os.path.abspath(localPath)
102+
else:
103+
# For GNU/Linux distributions
104+
searchPaths = ['/usr/share/doc/grass-doc/html', '/opt/grass/docs/html',
105+
'/usr/share/doc/grass/docs/html']
106+
for path in searchPaths:
107+
localPath = os.path.join(path, html)
108+
if os.path.exists(localPath):
109+
localDoc = os.path.abspath(localPath)
110+
111+
# Found the local documentation
112+
if localDoc:
113+
localDoc = QUrl.fromLocalFile(localDoc).toString()
114+
return False, localDoc
115+
116+
# Return the URL if local doc is not found
90117
return False, 'http://grass.osgeo.org/grass70/manuals/' + self.grass7Name + '.html'
91118

92119
def getParameterDescriptions(self):

0 commit comments

Comments
 (0)
Please sign in to comment.