Skip to content

Commit

Permalink
[GRASS] Rename more references to grass7
Browse files Browse the repository at this point in the history
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Mar 11, 2024
1 parent c6c13f1 commit a3bb769
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions python/plugins/grassprovider/ext/r_li.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@

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')


Expand Down
2 changes: 1 addition & 1 deletion python/plugins/grassprovider/ext/v_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions python/plugins/grassprovider/grass_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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)
Expand All @@ -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
)
Expand Down Expand Up @@ -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()}
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/grassprovider/grass_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand All @@ -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):
Expand Down Expand Up @@ -180,5 +180,5 @@ def canBeActivated(self):

def tr(self, string, context=''):
if context == '':
context = 'Grass7AlgorithmProvider'
context = 'GrassProvider'
return QCoreApplication.translate(context, string)
10 changes: 5 additions & 5 deletions python/plugins/grassprovider/grass_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a3bb769

Please sign in to comment.