From 17e7a62783e482afd2fbfbc1be5fb5c9be3eace2 Mon Sep 17 00:00:00 2001 From: Andrea Giudiceandrea Date: Sat, 9 Mar 2024 21:58:41 +0100 Subject: [PATCH] [GRASS] Rename more references to grass7 --- python/plugins/grassprovider/ext/r_li.py | 3 ++- python/plugins/grassprovider/ext/v_net.py | 2 +- python/plugins/grassprovider/grass_algorithm.py | 14 +++++++------- python/plugins/grassprovider/grass_provider.py | 10 +++++----- python/plugins/grassprovider/grass_utils.py | 10 +++++----- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/python/plugins/grassprovider/ext/r_li.py b/python/plugins/grassprovider/ext/r_li.py index 9a49286b2ae7..744e3a7d681d 100644 --- a/python/plugins/grassprovider/ext/r_li.py +++ b/python/plugins/grassprovider/ext/r_li.py @@ -34,9 +34,10 @@ def rliPath(): """Return r.li GRASS user dir""" + grass_version = GrassUtils.installedVersion().split('.')[0] if isWindows(): homeDir = win32api.GetShortPathName(os.path.expanduser('~')) - return os.path.join(homeDir, 'AppData', 'Roaming', 'GRASS7', 'r.li') + return os.path.join(homeDir, 'AppData', 'Roaming', f'GRASS{grass_version}', 'r.li') else: grass_version = GrassUtils.installedVersion().split('.')[0] return os.path.join(os.path.expanduser("~"), f'.grass{grass_version}', 'r.li') diff --git a/python/plugins/grassprovider/ext/v_net.py b/python/plugins/grassprovider/ext/v_net.py index 463e1c9867a1..35d056a7dd2b 100644 --- a/python/plugins/grassprovider/ext/v_net.py +++ b/python/plugins/grassprovider/ext/v_net.py @@ -47,7 +47,7 @@ def incorporatePoints(alg, parameters, context, feedback, pointLayerName='points lineLayer = alg.exportedLayers[networkLayerName] else: raise QgsProcessingException( - alg.tr('GRASS GIS 7 v.net requires a lines layer!')) + alg.tr('GRASS GIS v.net requires a lines layer!')) threshold = alg.parameterAsDouble(parameters, 'threshold', context) diff --git a/python/plugins/grassprovider/grass_algorithm.py b/python/plugins/grassprovider/grass_algorithm.py index 1641e02b6beb..4504177caf26 100644 --- a/python/plugins/grassprovider/grass_algorithm.py +++ b/python/plugins/grassprovider/grass_algorithm.py @@ -276,7 +276,7 @@ def _define_characteristics_from_parsed_description( except Exception as e: QgsMessageLog.logMessage( QCoreApplication.translate("GrassAlgorithm", - 'Could not open GRASS GIS 7 algorithm: {0}').format( + 'Could not open GRASS GIS algorithm: {0}').format( self._name), QCoreApplication.translate("GrassAlgorithm", 'Processing'), @@ -309,7 +309,7 @@ def _define_characteristics_from_parsed_description( param = QgsProcessingParameterExtent( self.GRASS_REGION_EXTENT_PARAMETER, - self.tr('GRASS GIS 7 region extent'), + self.tr('GRASS GIS region extent'), optional=True ) param.setFlags(param.flags() | QgsProcessingParameterDefinition.Flag.FlagAdvanced) @@ -319,7 +319,7 @@ def _define_characteristics_from_parsed_description( # Add a cellsize parameter param = QgsProcessingParameterNumber( self.GRASS_REGION_CELLSIZE_PARAMETER, - self.tr('GRASS GIS 7 region cellsize (leave 0 for default)'), + self.tr('GRASS GIS region cellsize (leave 0 for default)'), type=QgsProcessingParameterNumber.Type.Double, minValue=0.0, maxValue=sys.float_info.max + 1, defaultValue=0.0 ) @@ -450,8 +450,8 @@ def processAlgorithm(self, original_parameters, context, feedback): path = GrassUtils.grassPath() if path == '': raise QgsProcessingException( - self.tr('GRASS GIS 7 folder is not configured. Please ' - 'configure it before running GRASS GIS 7 algorithms.')) + self.tr('GRASS GIS folder is not configured. Please ' + 'configure it before running GRASS GIS algorithms.')) # make a copy of the original parameters dictionary - it gets modified by grass algorithms parameters = {k: v for k, v in original_parameters.items()} @@ -483,7 +483,7 @@ def processAlgorithm(self, original_parameters, context, feedback): getattr(self, fullName)(parameters, context, feedback) # Run GRASS - loglines = [self.tr('GRASS GIS 7 execution commands')] + loglines = [self.tr('GRASS GIS execution commands')] for line in self.commands: feedback.pushCommandInfo(line) loglines.append(line) @@ -493,7 +493,7 @@ def processAlgorithm(self, original_parameters, context, feedback): GrassUtils.executeGrass(self.commands, feedback, self.outputCommands) # If the session has been created outside of this algorithm, add - # the new GRASS GIS 7 layers to it otherwise finish the session + # the new GRASS GIS layers to it otherwise finish the session if existingSession: GrassUtils.addSessionLayers(self.exportedLayers) else: diff --git a/python/plugins/grassprovider/grass_provider.py b/python/plugins/grassprovider/grass_provider.py index 492a8361ff92..3975938d56d0 100644 --- a/python/plugins/grassprovider/grass_provider.py +++ b/python/plugins/grassprovider/grass_provider.py @@ -102,10 +102,10 @@ def parse_algorithms(self) -> List[QgsProcessingAlgorithm]: if alg.name().strip() != '': algs.append(alg) else: - QgsMessageLog.logMessage(self.tr('Could not open GRASS GIS 7 algorithm: {0}').format(algorithm_json.get('name')), self.tr('Processing'), Qgis.MessageLevel.Critical) + QgsMessageLog.logMessage(self.tr('Could not open GRASS GIS algorithm: {0}').format(algorithm_json.get('name')), self.tr('Processing'), Qgis.MessageLevel.Critical) except Exception as e: QgsMessageLog.logMessage( - self.tr('Could not open GRASS GIS 7 algorithm: {0}\n{1}').format(algorithm_json.get('name'), e), self.tr('Processing'), Qgis.MessageLevel.Critical) + self.tr('Could not open GRASS GIS algorithm: {0}\n{1}').format(algorithm_json.get('name'), e), self.tr('Processing'), Qgis.MessageLevel.Critical) else: # slow approach - pass txt files one by one for descriptionFile in folder.glob('*.txt'): @@ -115,10 +115,10 @@ def parse_algorithms(self) -> List[QgsProcessingAlgorithm]: if alg.name().strip() != '': algs.append(alg) else: - QgsMessageLog.logMessage(self.tr('Could not open GRASS GIS 7 algorithm: {0}').format(descriptionFile), self.tr('Processing'), Qgis.MessageLevel.Critical) + QgsMessageLog.logMessage(self.tr('Could not open GRASS GIS algorithm: {0}').format(descriptionFile), self.tr('Processing'), Qgis.MessageLevel.Critical) except Exception as e: QgsMessageLog.logMessage( - self.tr('Could not open GRASS GIS 7 algorithm: {0}\n{1}').format(descriptionFile, e), self.tr('Processing'), Qgis.MessageLevel.Critical) + self.tr('Could not open GRASS GIS algorithm: {0}\n{1}').format(descriptionFile, e), self.tr('Processing'), Qgis.MessageLevel.Critical) return algs def loadAlgorithms(self): @@ -180,5 +180,5 @@ def canBeActivated(self): def tr(self, string, context=''): if context == '': - context = 'Grass7AlgorithmProvider' + context = 'GrassProvider' return QCoreApplication.translate(context, string) diff --git a/python/plugins/grassprovider/grass_utils.py b/python/plugins/grassprovider/grass_utils.py index 50e8bf75a6dc..62acf546618b 100644 --- a/python/plugins/grassprovider/grass_utils.py +++ b/python/plugins/grassprovider/grass_utils.py @@ -354,7 +354,7 @@ def createTempMapset(): os.path.join(folder, 'PERMANENT', 'DEFAULT_WIND')) with open(os.path.join(folder, 'PERMANENT', 'MYNAME'), 'w') as outfile: outfile.write( - 'QGIS GRASS GIS 7 interface: temporary data processing location.\n') + 'QGIS GRASS GIS interface: temporary data processing location.\n') GrassUtils.writeGrassWindow(os.path.join(folder, 'PERMANENT', 'WIND')) mkdir(os.path.join(folder, 'PERMANENT', 'sqlite')) @@ -412,7 +412,7 @@ def prepareGrassExecution(commands): @staticmethod def executeGrass(commands, feedback, outputCommands=None): - loglines = [GrassUtils.tr('GRASS GIS 7 execution console output')] + loglines = [GrassUtils.tr('GRASS GIS execution console output')] grassOutDone = False command, grassenv = GrassUtils.prepareGrassExecution(commands) # QgsMessageLog.logMessage('exec: {}'.format(command), 'DEBUG', Qgis.Info) @@ -589,20 +589,20 @@ def checkGrassIsInstalled(ignorePreviousState=False): 'running GRASS algorithms.') if GrassUtils.command is None: return GrassUtils.tr( - 'GRASS GIS 7 binary {} can\'t be found on this system from a shell. ' + 'GRASS GIS binary {} can\'t be found on this system from a shell. ' 'Please install it or configure your PATH {} environment variable.'.format( '(grass.bat)' if isWindows() else '(grass.sh)', 'or OSGEO4W_ROOT' if isWindows() else '')) # GNU/Linux else: return GrassUtils.tr( - 'GRASS 7 can\'t be found on this system from a shell. ' + 'GRASS can\'t be found on this system from a shell. ' 'Please install it or configure your PATH environment variable.') @staticmethod def tr(string, context=''): if context == '': - context = 'Grass7Utils' + context = 'GrassUtils' return QCoreApplication.translate(context, string) @staticmethod