File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed
python/plugins/processing/algs/grass Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -96,9 +96,15 @@ def getIcon(self):
96
96
self ._icon = QIcon (os .path .join (pluginPath , 'images' , 'grass.svg' ))
97
97
return self ._icon
98
98
99
-
100
99
def help (self ):
101
- return False , 'http://grass.osgeo.org/grass64/manuals/' + self .grassName + '.html'
100
+ helpPath = GrassUtils .grassHelpPath ()
101
+ if helpPath == '' :
102
+ return False , None
103
+
104
+ if os .path .exists (helpPath ):
105
+ return False , QUrl .fromLocalFile (os .path .join (helpPath , '{}.html' .format (self .grassName ))).toString ()
106
+ else :
107
+ return False , helpPath + '{}.html' .format (self .grass7Name )
102
108
103
109
def getParameterDescriptions (self ):
104
110
descs = {}
@@ -162,7 +168,7 @@ def defineCharacteristicsFromFile(self):
162
168
elif isinstance (output , OutputVector ):
163
169
vectorOutputs += 1
164
170
if isinstance (output , OutputHTML ):
165
- self .addOutput (OutputFile ("rawoutput" , output .description +
171
+ self .addOutput (OutputFile ("rawoutput" , output .description +
166
172
" (raw output)" , "txt" ))
167
173
line = lines .readline ().strip ('\n ' ).strip ()
168
174
except Exception as e :
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ def initializeSettings(self):
63
63
ProcessingConfig .addSetting (Setting (self .getDescription (),
64
64
GrassUtils .GRASS_LOG_CONSOLE ,
65
65
self .tr ('Log console output' ), False ))
66
+ ProcessingConfig .addSetting (Setting (
67
+ self .getDescription (),
68
+ GrassUtils .GRASS_HELP_PATH ,
69
+ self .tr ('Location of GRASS docs' ),
70
+ GrassUtils .grassHelpPath ()))
66
71
67
72
def unload (self ):
68
73
AlgorithmProvider .unload (self )
@@ -71,6 +76,7 @@ def unload(self):
71
76
ProcessingConfig .removeSetting (GrassUtils .GRASS_WIN_SHELL )
72
77
ProcessingConfig .removeSetting (GrassUtils .GRASS_LOG_COMMANDS )
73
78
ProcessingConfig .removeSetting (GrassUtils .GRASS_LOG_CONSOLE )
79
+ ProcessingConfig .removeSetting (GrassUtils .GRASS_HELP_PATH )
74
80
75
81
def createAlgsList (self ):
76
82
self .preloadedAlgs = []
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ class GrassUtils:
50
50
GRASS_WIN_SHELL = 'GRASS_WIN_SHELL'
51
51
GRASS_LOG_COMMANDS = 'GRASS_LOG_COMMANDS'
52
52
GRASS_LOG_CONSOLE = 'GRASS_LOG_CONSOLE'
53
+ GRASS_HELP_PATH = 'GRASS_HELP_PATH'
53
54
54
55
sessionRunning = False
55
56
sessionLayers = {}
@@ -412,3 +413,27 @@ def tr(string, context=''):
412
413
if context == '' :
413
414
context = 'GrassUtils'
414
415
return QCoreApplication .translate (context , string )
416
+
417
+ @staticmethod
418
+ def grassHelpPath ():
419
+ helpPath = ProcessingConfig .getSetting (GrassUtils .GRASS_HELP_PATH )
420
+
421
+ if helpPath is None :
422
+ if isWindows ():
423
+ localPath = os .path .join (Grass7Utils .grassPath (), 'docs/html' )
424
+ if os .path .exists (localPath ):
425
+ helpPath = os .path .abspath (localPath )
426
+ elif isMac ():
427
+ localPath = '/Applications/GRASS-6.4.app/Contents/MacOS/docs/html'
428
+ if os .path .exists (localPath ):
429
+ helpPath = os .path .abspath (localPath )
430
+ else :
431
+ searchPaths = ['/usr/share/doc/grass-doc/html' ,
432
+ '/opt/grass/docs/html' ,
433
+ '/usr/share/doc/grass/docs/html' ]
434
+ for path in searchPaths :
435
+ if os .path .exists (path ):
436
+ helpPath = os .path .abspath (path )
437
+ break
438
+
439
+ return helpPath if helpPath is not None else 'http://grass.osgeo.org/grass64/manuals/'
You can’t perform that action at this time.
0 commit comments