Skip to content

Commit

Permalink
Merge branch 'main' into fix-FURB118-reimplemented-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Sep 28, 2024
2 parents f28e362 + ae5e4dd commit 1215abd
Show file tree
Hide file tree
Showing 68 changed files with 212 additions and 194 deletions.
4 changes: 1 addition & 3 deletions gui/wxpython/animation/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ def EvaluateInput(self, animationData):
mapCount.add(len(layer.maps))
windowIndex.append(anim.windowIndex)

if maps and stds:
temporalMode = TemporalMode.NONTEMPORAL
elif maps:
if (maps and stds) or maps:
temporalMode = TemporalMode.NONTEMPORAL
elif stds:
temporalMode = TemporalMode.TEMPORAL
Expand Down
17 changes: 10 additions & 7 deletions gui/wxpython/animation/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import wx
import copy
import datetime

from pathlib import Path

import wx.lib.filebrowsebutton as filebrowse
import wx.lib.scrolledpanel as SP
import wx.lib.colourselect as csel
Expand Down Expand Up @@ -488,7 +491,7 @@ def _create3DPanel(self, parent):
labelText=_("Workspace file:"),
dialogTitle=_("Choose workspace file to import 3D view parameters"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
fileMode=0,
fileMask="GRASS Workspace File (*.gxw)|*.gxw",
)
Expand Down Expand Up @@ -1089,7 +1092,7 @@ def _createDecorationsProperties(self, panel):
labelText=_("Image file:"),
dialogTitle=_("Choose image file"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
fileMode=wx.FD_OPEN,
changeCallback=self.OnSetImage,
)
Expand Down Expand Up @@ -1191,7 +1194,7 @@ def _createExportFormatPanel(self, notebook):
labelText=_("Directory:"),
dialogTitle=_("Choose directory for export"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
)

dirGridSizer = wx.GridBagSizer(hgap=5, vgap=5)
Expand Down Expand Up @@ -1219,7 +1222,7 @@ def _createExportFormatPanel(self, notebook):
labelText=_("GIF file:"),
dialogTitle=_("Choose file to save animation"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
fileMode=wx.FD_SAVE,
)
gifGridSizer = wx.GridBagSizer(hgap=5, vgap=5)
Expand All @@ -1242,7 +1245,7 @@ def _createExportFormatPanel(self, notebook):
labelText=_("SWF file:"),
dialogTitle=_("Choose file to save animation"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
fileMode=wx.FD_SAVE,
)
swfGridSizer = wx.GridBagSizer(hgap=5, vgap=5)
Expand Down Expand Up @@ -1273,7 +1276,7 @@ def _createExportFormatPanel(self, notebook):
labelText=_("AVI file:"),
dialogTitle=_("Choose file to save animation"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
fileMode=wx.FD_SAVE,
)
encodingLabel = StaticText(
Expand Down Expand Up @@ -1572,7 +1575,7 @@ def _export_file_validation(self, filebrowsebtn, file_path, file_postfix):
caption=_("Overwrite?"),
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION,
)
if not overwrite_dlg.ShowModal() == wx.ID_YES:
if overwrite_dlg.ShowModal() != wx.ID_YES:
overwrite_dlg.Destroy()
return False
overwrite_dlg.Destroy()
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/core/gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,11 @@ def _formatMsg(text):
for line in text.splitlines():
if len(line) == 0:
continue
elif "GRASS_INFO_MESSAGE" in line:
message += line.split(":", 1)[1].strip() + "\n"
elif "GRASS_INFO_WARNING" in line:
message += line.split(":", 1)[1].strip() + "\n"
elif "GRASS_INFO_ERROR" in line:
elif (
"GRASS_INFO_MESSAGE" in line
or "GRASS_INFO_WARNING" in line
or "GRASS_INFO_ERROR" in line
):
message += line.split(":", 1)[1].strip() + "\n"
elif "GRASS_INFO_END" in line:
return message
Expand Down
5 changes: 4 additions & 1 deletion gui/wxpython/core/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import os
import time

from pathlib import Path

import wx
from wx.lib.newevent import NewEvent

Expand Down Expand Up @@ -59,7 +62,7 @@ def on_modified(self, event):
not event.is_directory
and os.path.basename(event.src_path) == self.rcfile_name
):
timestamp = os.stat(event.src_path).st_mtime
timestamp = Path(event.src_path).stat().st_mtime
if timestamp - self.modified_time < 0.5:
return
self.modified_time = timestamp
Expand Down
7 changes: 6 additions & 1 deletion gui/wxpython/datacatalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import wx
import os

from pathlib import Path

from core.debug import Debug
from datacatalog.tree import DataCatalogTree
from datacatalog.toolbars import DataCatalogToolbar, DataCatalogSearch
Expand Down Expand Up @@ -200,7 +202,10 @@ def OnReloadCurrentMapset(self, event):
def OnAddGrassDB(self, event):
"""Add grass database"""
dlg = wx.DirDialog(
self, _("Choose GRASS data directory:"), os.getcwd(), wx.DD_DEFAULT_STYLE
self,
_("Choose GRASS data directory:"),
str(Path.cwd()),
wx.DD_DEFAULT_STYLE,
)
if dlg.ShowModal() == wx.ID_OK:
grassdatabase = dlg.GetPath()
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ def OnGeorect(self, event):
overwrite=self.overwrite,
)
if overwrite_dlg:
if not overwrite_dlg.ShowModal() == wx.ID_YES:
if overwrite_dlg.ShowModal() != wx.ID_YES:
overwrite_dlg.Destroy()
return
overwrite_dlg.Destroy()
Expand Down Expand Up @@ -1870,7 +1870,7 @@ def OnGeorect(self, event):
overwrite=self.overwrite,
)
if overwrite_dlg:
if not overwrite_dlg.ShowModal() == wx.ID_YES:
if overwrite_dlg.ShowModal() != wx.ID_YES:
overwrite_dlg.Destroy()
return
overwrite_dlg.Destroy()
Expand Down Expand Up @@ -2300,7 +2300,7 @@ def AdjustMap(self, newreg):
def OnZoomToSource(self, event):
"""Set target map window to match extents of source map window"""

if not self.MapWindow == self.TgtMapWindow:
if self.MapWindow != self.TgtMapWindow:
self.MapWindow = self.TgtMapWindow
self.Map = self.TgtMap
self.UpdateActive(self.TgtMapWindow)
Expand All @@ -2313,7 +2313,7 @@ def OnZoomToSource(self, event):
def OnZoomToTarget(self, event):
"""Set source map window to match extents of target map window"""

if not self.MapWindow == self.SrcMapWindow:
if self.MapWindow != self.SrcMapWindow:
self.MapWindow = self.SrcMapWindow
self.Map = self.SrcMap
self.UpdateActive(self.SrcMapWindow)
Expand Down Expand Up @@ -3323,7 +3323,7 @@ def OnSrcSelection(self, event):

tmp_map = self.srcselection.GetValue()

if not tmp_map == "" and not tmp_map == src_map:
if tmp_map not in ("", src_map):
self.new_src_map = tmp_map

def OnTgtRastSelection(self, event):
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gcp/mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def GetMapToolbar(self):
return self.toolbars["gcpdisp"]

def _setActiveMapWindow(self, mapWindow):
if not self.MapWindow == mapWindow:
if self.MapWindow != mapWindow:
self.MapWindow = mapWindow
self.Map = mapWindow.Map
self.UpdateActive(mapWindow)
Expand Down
12 changes: 4 additions & 8 deletions gui/wxpython/gmodeler/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ def OnRightClick(self, x, y, keys=0, attachment=0):
popupMenu = Menu()
popupMenu.Append(self.popupID["remove"], _("Remove"))
self.frame.Bind(wx.EVT_MENU, self.OnRemove, id=self.popupID["remove"])
if isinstance(shape, ModelAction) or isinstance(shape, ModelLoop):
if isinstance(shape, (ModelAction, ModelLoop)):
if shape.IsEnabled():
popupMenu.Append(self.popupID["enable"], _("Disable"))
self.frame.Bind(wx.EVT_MENU, self.OnDisable, id=self.popupID["enable"])
else:
popupMenu.Append(self.popupID["enable"], _("Enable"))
self.frame.Bind(wx.EVT_MENU, self.OnEnable, id=self.popupID["enable"])
if isinstance(shape, ModelAction) or isinstance(shape, ModelComment):
if isinstance(shape, (ModelAction, ModelComment)):
popupMenu.AppendSeparator()
if isinstance(shape, ModelAction):
popupMenu.Append(self.popupID["label"], _("Set label"))
self.frame.Bind(wx.EVT_MENU, self.OnSetLabel, id=self.popupID["label"])
if isinstance(shape, ModelAction) or isinstance(shape, ModelComment):
if isinstance(shape, (ModelAction, ModelComment)):
popupMenu.Append(self.popupID["comment"], _("Set comment"))
self.frame.Bind(wx.EVT_MENU, self.OnSetComment, id=self.popupID["comment"])

Expand Down Expand Up @@ -377,11 +377,7 @@ def OnRightClick(self, x, y, keys=0, attachment=0):
if self.GetShape().IsIntermediate():
popupMenu.Enable(self.popupID["display"], False)

if (
isinstance(shape, ModelData)
or isinstance(shape, ModelAction)
or isinstance(shape, ModelLoop)
):
if isinstance(shape, (ModelData, ModelAction, ModelLoop)):
popupMenu.AppendSeparator()
popupMenu.Append(self.popupID["props"], _("Properties"))
self.frame.Bind(wx.EVT_MENU, self.OnProperties, id=self.popupID["props"])
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,7 @@ def _writeItem(self, item, ignoreBlock=True, variables={}):
self._writePythonAction(
item, variables, self.model.GetIntermediateData()[:3]
)
elif isinstance(item, ModelLoop) or isinstance(item, ModelCondition):
elif isinstance(item, (ModelLoop, ModelCondition)):
# substitute condition
cond = item.GetLabel()
for variable in self.model.GetVariables():
Expand Down
8 changes: 5 additions & 3 deletions gui/wxpython/gmodeler/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import random
import math

from pathlib import Path

import wx

from wx.lib import ogl
Expand Down Expand Up @@ -834,7 +836,7 @@ def OnModelOpen(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Choose model file"),
defaultDir=os.getcwd(),
defaultDir=str(Path.cwd()),
wildcard=_("GRASS Model File (*.gxm)|*.gxm"),
)
if dlg.ShowModal() == wx.ID_OK:
Expand Down Expand Up @@ -892,7 +894,7 @@ def OnModelSaveAs(self, event=None):
dlg = wx.FileDialog(
parent=self,
message=_("Choose file to save current model"),
defaultDir=os.getcwd(),
defaultDir=str(Path.cwd()),
wildcard=_("GRASS Model File (*.gxm)|*.gxm"),
style=wx.FD_SAVE,
)
Expand Down Expand Up @@ -1740,7 +1742,7 @@ def SaveAs(self, force=False):
parent=self,
message=_("Choose file to save"),
defaultFile=os.path.basename(self.parent.GetModelFile(ext=False)),
defaultDir=os.getcwd(),
defaultDir=str(Path.cwd()),
wildcard=fn_wildcard,
style=wx.FD_SAVE,
)
Expand Down
7 changes: 4 additions & 3 deletions gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import codecs

from threading import Thread
from pathlib import Path

import wx

Expand Down Expand Up @@ -2034,7 +2035,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar
dialogTitle=_("Choose %s")
% p.get("description", _("file")).lower(),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
fileMode=fmode,
changeCallback=self.OnSetValue,
)
Expand Down Expand Up @@ -2145,7 +2146,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar
dialogTitle=_("Choose %s")
% p.get("description", _("Directory")),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
newDirectory=True,
changeCallback=self.OnSetValue,
)
Expand Down Expand Up @@ -2624,7 +2625,7 @@ def OnFileSave(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Save input as..."),
defaultDir=os.getcwd(),
defaultDir=str(Path.cwd()),
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
)

Expand Down
10 changes: 6 additions & 4 deletions gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import glob
import ctypes

from pathlib import Path

import wx

from core import globalvar
Expand Down Expand Up @@ -1558,7 +1560,7 @@ def __init__(
labelText=_("File:"),
dialogTitle=_("Choose file to import"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
changeCallback=self.OnUpdate,
fileMask=fileMask,
)
Expand All @@ -1575,7 +1577,7 @@ def __init__(
labelText=_("Directory:"),
dialogTitle=_("Choose input directory"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
changeCallback=self.OnUpdate,
)
browse.GetChildren()[1].SetName("GdalSelectDataSource")
Expand Down Expand Up @@ -1628,7 +1630,7 @@ def __init__(
labelText=_("Name:"),
dialogTitle=_("Choose file"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
changeCallback=self.OnUpdate,
)
browse.GetChildren()[1].SetName("GdalSelectDataSource")
Expand Down Expand Up @@ -1663,7 +1665,7 @@ def __init__(
labelText=_("Directory:"),
dialogTitle=_("Choose input directory"),
buttonText=_("Browse"),
startDirectory=os.getcwd(),
startDirectory=str(Path.cwd()),
changeCallback=self.OnUpdate,
)
self.dbWidgets["dirbrowse"] = browse
Expand Down
5 changes: 3 additions & 2 deletions gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import os
import sys

from pathlib import Path

try:
import pwd

Expand Down Expand Up @@ -2425,8 +2427,7 @@ def LoadData(self):

for mapset in self.parent.all_mapsets_ordered:
index = self.InsertItem(self.GetItemCount(), mapset)
mapsetPath = os.path.join(locationPath, mapset)
stat_info = os.stat(mapsetPath)
stat_info = Path(locationPath, mapset).stat()
if havePwd:
try:
self.SetItem(index, 1, "%s" % pwd.getpwuid(stat_info.st_uid)[0])
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/pyedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def SaveAs(self):
dlg = wx.FileDialog(
parent=self.guiparent,
message=_("Choose file to save"),
defaultDir=os.getcwd(),
defaultDir=str(Path.cwd()),
wildcard=_("Python script (*.py)|*.py"),
style=wx.FD_SAVE,
)
Expand Down Expand Up @@ -466,7 +466,7 @@ def Open(self):
dlg = wx.FileDialog(
parent=self.guiparent,
message=_("Open file"),
defaultDir=os.getcwd(),
defaultDir=str(Path.cwd()),
wildcard=_("Python script (*.py)|*.py"),
style=wx.FD_OPEN,
)
Expand Down
Loading

0 comments on commit 1215abd

Please sign in to comment.