diff --git a/gui/wxpython/animation/controller.py b/gui/wxpython/animation/controller.py index 1a920f77de7..1a8cb1fe9cc 100644 --- a/gui/wxpython/animation/controller.py +++ b/gui/wxpython/animation/controller.py @@ -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 diff --git a/gui/wxpython/animation/dialogs.py b/gui/wxpython/animation/dialogs.py index 3d70dbd2639..f6e4db341c5 100644 --- a/gui/wxpython/animation/dialogs.py +++ b/gui/wxpython/animation/dialogs.py @@ -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 @@ -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", ) @@ -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, ) @@ -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) @@ -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) @@ -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) @@ -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( @@ -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() diff --git a/gui/wxpython/core/gcmd.py b/gui/wxpython/core/gcmd.py index b93789f22f7..eb40ec57103 100644 --- a/gui/wxpython/core/gcmd.py +++ b/gui/wxpython/core/gcmd.py @@ -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 diff --git a/gui/wxpython/core/watchdog.py b/gui/wxpython/core/watchdog.py index 652bc1d755d..591bb36b477 100644 --- a/gui/wxpython/core/watchdog.py +++ b/gui/wxpython/core/watchdog.py @@ -19,6 +19,9 @@ import os import time + +from pathlib import Path + import wx from wx.lib.newevent import NewEvent @@ -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 diff --git a/gui/wxpython/datacatalog/catalog.py b/gui/wxpython/datacatalog/catalog.py index 880190b0943..4835061d968 100644 --- a/gui/wxpython/datacatalog/catalog.py +++ b/gui/wxpython/datacatalog/catalog.py @@ -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 @@ -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() diff --git a/gui/wxpython/gcp/manager.py b/gui/wxpython/gcp/manager.py index e5e0dd37471..a96555fe271 100644 --- a/gui/wxpython/gcp/manager.py +++ b/gui/wxpython/gcp/manager.py @@ -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() @@ -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() @@ -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) @@ -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) @@ -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): diff --git a/gui/wxpython/gcp/mapdisplay.py b/gui/wxpython/gcp/mapdisplay.py index 66daa70d2ca..0681b03e4e8 100644 --- a/gui/wxpython/gcp/mapdisplay.py +++ b/gui/wxpython/gcp/mapdisplay.py @@ -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) diff --git a/gui/wxpython/gmodeler/canvas.py b/gui/wxpython/gmodeler/canvas.py index 7c604ec6624..bfe5f7a90af 100644 --- a/gui/wxpython/gmodeler/canvas.py +++ b/gui/wxpython/gmodeler/canvas.py @@ -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"]) @@ -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"]) diff --git a/gui/wxpython/gmodeler/model.py b/gui/wxpython/gmodeler/model.py index a609a1c8bd8..59ea791192c 100644 --- a/gui/wxpython/gmodeler/model.py +++ b/gui/wxpython/gmodeler/model.py @@ -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(): diff --git a/gui/wxpython/gmodeler/panels.py b/gui/wxpython/gmodeler/panels.py index 93ef770efe1..416a9b85592 100644 --- a/gui/wxpython/gmodeler/panels.py +++ b/gui/wxpython/gmodeler/panels.py @@ -25,6 +25,8 @@ import random import math +from pathlib import Path + import wx from wx.lib import ogl @@ -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: @@ -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, ) @@ -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, ) diff --git a/gui/wxpython/gui_core/forms.py b/gui/wxpython/gui_core/forms.py index 84fd849908c..74bcc00f85a 100644 --- a/gui/wxpython/gui_core/forms.py +++ b/gui/wxpython/gui_core/forms.py @@ -58,6 +58,7 @@ import codecs from threading import Thread +from pathlib import Path import wx @@ -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, ) @@ -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, ) @@ -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, ) diff --git a/gui/wxpython/gui_core/gselect.py b/gui/wxpython/gui_core/gselect.py index 4bb9af5b50e..af71cc4f550 100644 --- a/gui/wxpython/gui_core/gselect.py +++ b/gui/wxpython/gui_core/gselect.py @@ -47,6 +47,8 @@ import glob import ctypes +from pathlib import Path + import wx from core import globalvar @@ -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, ) @@ -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") @@ -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") @@ -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 diff --git a/gui/wxpython/gui_core/preferences.py b/gui/wxpython/gui_core/preferences.py index a35d902bc7f..724e4a5aec0 100644 --- a/gui/wxpython/gui_core/preferences.py +++ b/gui/wxpython/gui_core/preferences.py @@ -28,6 +28,8 @@ import os import sys +from pathlib import Path + try: import pwd @@ -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]) diff --git a/gui/wxpython/gui_core/pyedit.py b/gui/wxpython/gui_core/pyedit.py index 2de2d45b066..5958ffb6d68 100644 --- a/gui/wxpython/gui_core/pyedit.py +++ b/gui/wxpython/gui_core/pyedit.py @@ -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, ) @@ -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, ) diff --git a/gui/wxpython/gui_core/vselect.py b/gui/wxpython/gui_core/vselect.py index 0ff30afaafd..16bb64b7a57 100644 --- a/gui/wxpython/gui_core/vselect.py +++ b/gui/wxpython/gui_core/vselect.py @@ -232,7 +232,7 @@ def AddVecInfo(self, vInfoDictTMP) -> bool: if self._dialog: self.slist.AddItem(vInfoDictTMP) - return not len(self.selectedFeatures) == 0 + return len(self.selectedFeatures) != 0 def _draw(self): """Call class 'VectorSelectHighlighter' to draw selected features""" diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index 69c18780249..606c364c76f 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -570,7 +570,7 @@ def OnZoomMenu(self, event): def OnZoomToTraining(self, event): """Set preview display to match extents of training display""" - if not self.MapWindow == self.GetSecondWindow(): + if self.MapWindow != self.GetSecondWindow(): self.MapWindow = self.GetSecondWindow() self.Map = self.GetSecondMap() self.UpdateActive(self.GetSecondWindow()) @@ -583,7 +583,7 @@ def OnZoomToTraining(self, event): def OnZoomToPreview(self, event): """Set preview display to match extents of training display""" - if not self.MapWindow == self.GetFirstWindow(): + if self.MapWindow != self.GetFirstWindow(): self.MapWindow = self.GetFirstWindow() self.Map = self.GetFirstMap() self.UpdateActive(self.GetFirstWindow()) diff --git a/gui/wxpython/iclass/g.gui.iclass.html b/gui/wxpython/iclass/g.gui.iclass.html index f6169b1d8f6..dd789cd75b5 100644 --- a/gui/wxpython/iclass/g.gui.iclass.html +++ b/gui/wxpython/iclass/g.gui.iclass.html @@ -35,7 +35,6 @@
wxIClass can also import training areas defined in a vector layer. In that case the program expects the vector layer to have the following columns defined: +
The spectral signatures are composed of region means and covariance matrices.
These region means and covariance matrices are used in
diff --git a/gui/wxpython/image2target/ii2t_gis_set.py b/gui/wxpython/image2target/ii2t_gis_set.py
index 0f51d969e93..187b01d1740 100644
--- a/gui/wxpython/image2target/ii2t_gis_set.py
+++ b/gui/wxpython/image2target/ii2t_gis_set.py
@@ -27,6 +27,8 @@
import platform
import getpass
+from pathlib import Path
+
from core import globalvar
import wx
import wx.lib.mixins.listctrl as listmix
@@ -315,7 +317,7 @@ def _set_properties(self, version, revision):
if os.path.isdir(os.getenv("HOME")):
self.gisdbase = os.getenv("HOME")
else:
- self.gisdbase = os.getcwd()
+ self.gisdbase = str(Path.cwd())
try:
self.tgisdbase.SetValue(self.gisdbase)
except UnicodeDecodeError:
diff --git a/gui/wxpython/image2target/ii2t_manager.py b/gui/wxpython/image2target/ii2t_manager.py
index 17811ceceb1..1c9958c9cef 100644
--- a/gui/wxpython/image2target/ii2t_manager.py
+++ b/gui/wxpython/image2target/ii2t_manager.py
@@ -2245,7 +2245,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)
@@ -2258,7 +2258,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)
@@ -3282,7 +3282,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):
diff --git a/gui/wxpython/image2target/ii2t_mapdisplay.py b/gui/wxpython/image2target/ii2t_mapdisplay.py
index b85a70a152f..c148eb314d2 100644
--- a/gui/wxpython/image2target/ii2t_mapdisplay.py
+++ b/gui/wxpython/image2target/ii2t_mapdisplay.py
@@ -567,7 +567,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)
diff --git a/gui/wxpython/iscatt/plots.py b/gui/wxpython/iscatt/plots.py
index 08afe5906ed..a29098e8bcd 100644
--- a/gui/wxpython/iscatt/plots.py
+++ b/gui/wxpython/iscatt/plots.py
@@ -168,7 +168,7 @@ def SetEmpty(self):
return self.polygon_drawer.SetEmpty()
def OnRelease(self, event):
- if not self.mode == "zoom":
+ if self.mode != "zoom":
return
self.zoom_rect.set_visible(False)
self.ZoomRectangle(event)
@@ -348,7 +348,7 @@ def ZoomWheel(self, event):
def ZoomRectangle(self, event):
# get the current x and y limits
- if not self.mode == "zoom":
+ if self.mode != "zoom":
return
if event.inaxes is None:
return
@@ -394,7 +394,7 @@ def OnCanvasLeave(self, event):
def PanMotion(self, event):
"on mouse movement"
- if not self.mode == "pan":
+ if self.mode != "pan":
return
if event.inaxes is None:
return
@@ -426,7 +426,7 @@ def PanMotion(self, event):
self.canvas.draw()
def ZoomRectMotion(self, event):
- if not self.mode == "zoom":
+ if self.mode != "zoom":
return
if event.inaxes is None:
return
@@ -811,11 +811,11 @@ def _deleteVertex(self, event):
coords = []
for i, tup in enumerate(self.pol.xy):
- if i == ind:
- continue
- elif i == 0 and ind == len(self.pol.xy) - 1:
- continue
- elif i == len(self.pol.xy) - 1 and ind == 0:
+ if (
+ i == ind
+ or (i == 0 and ind == len(self.pol.xy) - 1)
+ or (i == len(self.pol.xy) - 1 and ind == 0)
+ ):
continue
coords.append(tup)
@@ -866,7 +866,7 @@ def _addVertex(self, event):
def motion_notify_callback(self, event):
"on mouse movement"
- if not self.mode == "move_vertex":
+ if self.mode != "move_vertex":
return
if not self.showverts:
return
diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py
index a17b168f747..4eae371f68b 100644
--- a/gui/wxpython/lmgr/frame.py
+++ b/gui/wxpython/lmgr/frame.py
@@ -24,6 +24,8 @@
import platform
import re
+from pathlib import Path
+
from core import globalvar
import wx
import wx.aui
@@ -848,7 +850,7 @@ def OnRunModel(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Choose model to run"),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("GRASS Model File (*.gxm)|*.gxm"),
)
if dlg.ShowModal() == wx.ID_OK:
@@ -1223,7 +1225,7 @@ def OnRunScript(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Choose script file to run"),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("Python script (*.py)|*.py|Bash script (*.sh)|*.sh"),
)
@@ -1377,9 +1379,7 @@ def write_beginning(parameter=None, command=None):
self._giface.WriteCmdLog(" ".join(command))
def write_changed():
- self._giface.WriteLog(
- _('Working directory changed to:\n"%s"') % os.getcwd()
- )
+ self._giface.WriteLog(_('Working directory changed to:\n"%s"') % Path.cwd())
def write_end():
self._giface.WriteCmdLog(" ")
@@ -1433,7 +1433,7 @@ def write_help():
dlg = wx.DirDialog(
parent=self,
message=_("Choose a working directory"),
- defaultPath=os.getcwd(),
+ defaultPath=str(Path.cwd()),
)
if dlg.ShowModal() == wx.ID_OK:
diff --git a/gui/wxpython/lmgr/workspace.py b/gui/wxpython/lmgr/workspace.py
index bb40469fa56..a593c19b19c 100644
--- a/gui/wxpython/lmgr/workspace.py
+++ b/gui/wxpython/lmgr/workspace.py
@@ -18,6 +18,8 @@
import xml.etree.ElementTree as ET
+from pathlib import Path
+
import wx
import wx.aui
@@ -103,7 +105,7 @@ def Open(self):
dlg = wx.FileDialog(
parent=self.lmgr,
message=_("Choose workspace file"),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("GRASS Workspace File (*.gxw)|*.gxw"),
)
@@ -362,7 +364,7 @@ def SaveAs(self):
dlg = wx.FileDialog(
parent=self.lmgr,
message=_("Choose file to save current workspace"),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("GRASS Workspace File (*.gxw)|*.gxw"),
style=wx.FD_SAVE,
)
diff --git a/gui/wxpython/location_wizard/wizard.py b/gui/wxpython/location_wizard/wizard.py
index 7ba03ebee04..2cccdf5e301 100644
--- a/gui/wxpython/location_wizard/wizard.py
+++ b/gui/wxpython/location_wizard/wizard.py
@@ -38,6 +38,8 @@
import locale
import functools
+from pathlib import Path
+
import wx
import wx.lib.mixins.listctrl as listmix
from core import globalvar
@@ -318,7 +320,10 @@ def OnChangeName(self, event):
def OnBrowse(self, event):
"""Choose GRASS data directory"""
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:
self.grassdatabase = dlg.GetPath()
@@ -1493,7 +1498,7 @@ def OnText(self, event):
def OnBrowse(self, event):
"""Choose file"""
dlg = wx.FileDialog(
- self, _("Select georeferenced file"), os.getcwd(), "", "*.*", wx.FD_OPEN
+ self, _("Select georeferenced file"), str(Path.cwd()), "", "*.*", wx.FD_OPEN
)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
@@ -1977,7 +1982,7 @@ def OnBrowse(self, event):
"""Define path for IAU code file"""
path = os.path.dirname(self.tfile.GetValue())
if not path:
- path = os.getcwd()
+ path = str(Path.cwd())
dlg = wx.FileDialog(
parent=self,
diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py
index 3b9b7f50261..8fc8dc8dde7 100644
--- a/gui/wxpython/main_window/frame.py
+++ b/gui/wxpython/main_window/frame.py
@@ -25,6 +25,8 @@
import platform
import re
+from pathlib import Path
+
from core import globalvar
try:
@@ -971,7 +973,7 @@ def OnRunModel(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Choose model to run"),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("GRASS Model File (*.gxm)|*.gxm"),
)
if dlg.ShowModal() == wx.ID_OK:
@@ -1374,7 +1376,7 @@ def OnRunScript(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Choose script file to run"),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("Python script (*.py)|*.py|Bash script (*.sh)|*.sh"),
)
@@ -1528,9 +1530,7 @@ def write_beginning(parameter=None, command=None):
self._giface.WriteCmdLog(" ".join(command))
def write_changed():
- self._giface.WriteLog(
- _('Working directory changed to:\n"%s"') % os.getcwd()
- )
+ self._giface.WriteLog(_('Working directory changed to:\n"%s"') % Path.cwd())
def write_end():
self._giface.WriteCmdLog(" ")
@@ -1584,7 +1584,7 @@ def write_help():
dlg = wx.DirDialog(
parent=self,
message=_("Choose a working directory"),
- defaultPath=os.getcwd(),
+ defaultPath=str(Path.cwd()),
)
if dlg.ShowModal() == wx.ID_OK:
diff --git a/gui/wxpython/mapdisp/frame.py b/gui/wxpython/mapdisp/frame.py
index 0b948f63794..f13ffbe0a81 100644
--- a/gui/wxpython/mapdisp/frame.py
+++ b/gui/wxpython/mapdisp/frame.py
@@ -831,7 +831,7 @@ def _DToRastDone():
overwrite=overwrite,
getErrorMsg=True,
)
- if not returncode == 0:
+ if returncode != 0:
self._giface.WriteError(_("Failed to run d.to.rast:\n") + messages)
return
# set region for composite
@@ -839,7 +839,7 @@ def _DToRastDone():
returncode, messages = RunCommand(
"g.region", raster=tmpName + ".red", quiet=True, getErrorMsg=True
)
- if not returncode == 0:
+ if returncode != 0:
gs.del_temp_region()
self._giface.WriteError(_("Failed to run d.to.rast:\n") + messages)
return
@@ -862,7 +862,7 @@ def _DToRastDone():
quiet=True,
name=[tmpName + ".red", tmpName + ".green", tmpName + ".blue"],
)
- if not returncode == 0:
+ if returncode != 0:
self._giface.WriteError(_("Failed to run d.to.rast:\n") + messages)
gs.try_remove(pngFile)
return
diff --git a/gui/wxpython/mapwin/decorations.py b/gui/wxpython/mapwin/decorations.py
index 7ab010a1d3f..24db63d8492 100644
--- a/gui/wxpython/mapwin/decorations.py
+++ b/gui/wxpython/mapwin/decorations.py
@@ -209,9 +209,7 @@ def CmdIsValid(self) -> bool:
inputs = 0
for param in self._cmd[1:]:
param = param.split("=")
- if len(param) == 1:
- inputs += 1
- elif param[0] == "text" and len(param) == 2:
+ if len(param) == 1 or (param[0] == "text" and len(param) == 2):
inputs += 1
return inputs >= 1
@@ -313,11 +311,11 @@ def CmdIsValid(self) -> bool:
inputs = 0
for param in self._cmd[1:]:
param = param.split("=")
- if len(param) == 1:
- inputs += 1
- elif param[0] == "raster" and len(param) == 2:
- inputs += 1
- elif param[0] == "raster_3d" and len(param) == 2:
+ if (
+ len(param) == 1
+ or (param[0] == "raster" and len(param) == 2)
+ or (param[0] == "raster_3d" and len(param) == 2)
+ ):
inputs += 1
return inputs == 1
diff --git a/gui/wxpython/modules/colorrules.py b/gui/wxpython/modules/colorrules.py
index b5b1047382e..5093cd7cf25 100644
--- a/gui/wxpython/modules/colorrules.py
+++ b/gui/wxpython/modules/colorrules.py
@@ -27,6 +27,8 @@
import copy
import tempfile
+from pathlib import Path
+
import wx
import wx.lib.colourselect as csel
import wx.lib.scrolledpanel as scrolled
@@ -448,7 +450,7 @@ def _createFileSelection(self, parent):
dialogTitle=_("Choose file to load color table"),
buttonText=_("Load"),
toolTip=_("Type filename or click to choose file and load color table"),
- startDirectory=os.getcwd(),
+ startDirectory=str(Path.cwd()),
fileMode=wx.FD_OPEN,
changeCallback=self.OnLoadRulesFile,
)
@@ -460,7 +462,7 @@ def _createFileSelection(self, parent):
dialogTitle=_("Choose file to save color table"),
toolTip=_("Type filename or click to choose file and save color table"),
buttonText=_("Save"),
- startDirectory=os.getcwd(),
+ startDirectory=str(Path.cwd()),
fileMode=wx.FD_SAVE,
changeCallback=self.OnSaveRulesFile,
)
diff --git a/gui/wxpython/modules/import_export.py b/gui/wxpython/modules/import_export.py
index 15d4f76b586..03d179ffc2f 100644
--- a/gui/wxpython/modules/import_export.py
+++ b/gui/wxpython/modules/import_export.py
@@ -22,6 +22,8 @@
import os
+from pathlib import Path
+
import wx
from core import globalvar
import wx.lib.filebrowsebutton as filebrowse
@@ -836,7 +838,7 @@ def __init__(self, parent, giface):
labelText="",
dialogTitle=_("Choose DXF file to import"),
buttonText=_("Browse"),
- startDirectory=os.getcwd(),
+ startDirectory=str(Path.cwd()),
fileMode=0,
changeCallback=self.OnSetDsn,
fileMask="DXF File (*.dxf)|*.dxf",
diff --git a/gui/wxpython/nviz/mapwindow.py b/gui/wxpython/nviz/mapwindow.py
index eaf0d266d4e..550939da7ce 100644
--- a/gui/wxpython/nviz/mapwindow.py
+++ b/gui/wxpython/nviz/mapwindow.py
@@ -534,7 +534,7 @@ def OnKeyDown(self, event):
Used for fly-through mode.
"""
- if not self.mouse["use"] == "fly":
+ if self.mouse["use"] != "fly":
return
key = event.GetKeyCode()
@@ -596,7 +596,7 @@ def OnKeyUp(self, event):
Used for fly-through mode.
"""
- if not self.mouse["use"] == "fly":
+ if self.mouse["use"] != "fly":
return
key = event.GetKeyCode()
diff --git a/gui/wxpython/nviz/tools.py b/gui/wxpython/nviz/tools.py
index a1b0a9fcb1b..0659c5cc2ba 100644
--- a/gui/wxpython/nviz/tools.py
+++ b/gui/wxpython/nviz/tools.py
@@ -23,6 +23,8 @@
import sys
import copy
+from pathlib import Path
+
import wx
import wx.lib.colourselect as csel
import wx.lib.scrolledpanel as SP
@@ -668,7 +670,7 @@ def _createAnimationPage(self):
vSizer = wx.BoxSizer(wx.VERTICAL)
gridSizer = wx.GridBagSizer(vgap=5, hgap=10)
- pwd = os.getcwd()
+ pwd = str(Path.cwd())
dir = filebrowse.DirBrowseButton(
parent=panel,
id=wx.ID_ANY,
diff --git a/gui/wxpython/nviz/wxnviz.py b/gui/wxpython/nviz/wxnviz.py
index 8002d6f32d2..e80a9fc9382 100644
--- a/gui/wxpython/nviz/wxnviz.py
+++ b/gui/wxpython/nviz/wxnviz.py
@@ -83,7 +83,7 @@ def print_progress(value):
"""Redirect progress info"""
global progress
if progress:
- if not progress.GetRange() == 100:
+ if progress.GetRange() != 100:
progress.SetRange(100)
progress.SetValue(value)
else:
diff --git a/gui/wxpython/photo2image/ip2i_manager.py b/gui/wxpython/photo2image/ip2i_manager.py
index f251a1fa36e..e27e763fb2a 100644
--- a/gui/wxpython/photo2image/ip2i_manager.py
+++ b/gui/wxpython/photo2image/ip2i_manager.py
@@ -1531,7 +1531,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)
@@ -1544,7 +1544,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)
@@ -2381,7 +2381,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):
diff --git a/gui/wxpython/photo2image/ip2i_mapdisplay.py b/gui/wxpython/photo2image/ip2i_mapdisplay.py
index f85be35ec4a..aa085f2b43a 100644
--- a/gui/wxpython/photo2image/ip2i_mapdisplay.py
+++ b/gui/wxpython/photo2image/ip2i_mapdisplay.py
@@ -559,7 +559,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)
diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py
index 15cb244391f..41493795893 100644
--- a/gui/wxpython/psmap/dialogs.py
+++ b/gui/wxpython/psmap/dialogs.py
@@ -38,6 +38,7 @@
import string
from copy import deepcopy
from operator import itemgetter
+from pathlib import Path
import wx
import wx.lib.agw.floatspin as fs
@@ -5964,7 +5965,7 @@ def OnPositionType(self, event):
def _getImageDirectory(self):
"""Default image directory"""
- return os.getcwd()
+ return str(Path.cwd())
def _addConvergence(self, panel, gridBagSizer):
pass
diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py
index 3effc33cd4d..fa4a150aa3b 100644
--- a/gui/wxpython/psmap/frame.py
+++ b/gui/wxpython/psmap/frame.py
@@ -308,7 +308,7 @@ def OnPsMapDialog(self, event):
def OnPDFFile(self, event):
"""Generate PDF from PS with ps2pdf if available"""
- if not sys.platform == "win32":
+ if sys.platform != "win32":
try:
p = gs.Popen(["ps2pdf"], stderr=gs.PIPE)
p.stderr.close()
diff --git a/gui/wxpython/rdigit/dialogs.py b/gui/wxpython/rdigit/dialogs.py
index 650b75feb63..c632a84c0fe 100644
--- a/gui/wxpython/rdigit/dialogs.py
+++ b/gui/wxpython/rdigit/dialogs.py
@@ -114,7 +114,7 @@ def OnOK(self, event):
caption=_("Overwrite?"),
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION,
)
- if not dlgOverwrite.ShowModal() == wx.ID_YES:
+ if dlgOverwrite.ShowModal() != wx.ID_YES:
dlgOverwrite.Destroy()
return
else:
diff --git a/gui/wxpython/tplot/frame.py b/gui/wxpython/tplot/frame.py
index 23e8d0e512f..8994485dacc 100755
--- a/gui/wxpython/tplot/frame.py
+++ b/gui/wxpython/tplot/frame.py
@@ -20,6 +20,7 @@
"""
import os
from itertools import cycle
+from pathlib import Path
import numpy as np
import wx
@@ -372,7 +373,7 @@ def _layout(self):
labelText="",
dialogTitle=_("CVS path"),
buttonText=_("Browse"),
- startDirectory=os.getcwd(),
+ startDirectory=str(Path.cwd()),
fileMode=wx.FD_SAVE,
)
self.headerLabel = StaticText(
diff --git a/gui/wxpython/vdigit/wxdigit.py b/gui/wxpython/vdigit/wxdigit.py
index ddcdc5a2755..154d5ab7c81 100644
--- a/gui/wxpython/vdigit/wxdigit.py
+++ b/gui/wxpython/vdigit/wxdigit.py
@@ -1084,7 +1084,7 @@ def EditLine(self, line, coords):
# apply snapping (node or vertex)
snap = self._getSnapMode()
if snap != NO_SNAP:
- modeSnap = not (snap == SNAP)
+ modeSnap = snap != SNAP
Vedit_snap_line(
self.poMapInfo,
self.popoBgMapInfo,
@@ -1889,7 +1889,7 @@ def _addFeature(self, ftype, coords, layer, cat, snap, threshold):
if snap != NO_SNAP:
# apply snapping (node or vertex)
- modeSnap = not (snap == SNAP)
+ modeSnap = snap != SNAP
Vedit_snap_line(
self.poMapInfo,
self.popoBgMapInfo,
diff --git a/gui/wxpython/vdigit/wxdisplay.py b/gui/wxpython/vdigit/wxdisplay.py
index b747f3fa44f..9085aae8caf 100644
--- a/gui/wxpython/vdigit/wxdisplay.py
+++ b/gui/wxpython/vdigit/wxdisplay.py
@@ -868,10 +868,7 @@ def GetSelectedVertex(self, pos):
pos[0], pos[1], 0.0, points.x[idx], points.y[idx], points.z[idx], 0
)
- if idx == 0:
- minDist = dist
- Gid = idx
- elif minDist > dist:
+ if idx == 0 or minDist > dist:
minDist = dist
Gid = idx
diff --git a/gui/wxpython/vnet/dialogs.py b/gui/wxpython/vnet/dialogs.py
index 3d829ffd7be..a445b01e8eb 100644
--- a/gui/wxpython/vnet/dialogs.py
+++ b/gui/wxpython/vnet/dialogs.py
@@ -1952,9 +1952,7 @@ def SetVirtualData(self, row, column, text):
text = DegreesToRadians(text)
# Tested allowed range of values
- if text > math.pi:
- text = 0.0
- elif text < -math.pi:
+ if text > math.pi or text < -math.pi:
text = 0.0
self.data.SetValue(text, row, column)
diff --git a/gui/wxpython/vnet/vnet_core.py b/gui/wxpython/vnet/vnet_core.py
index 17d85ef6ca4..ac7625a4c22 100644
--- a/gui/wxpython/vnet/vnet_core.py
+++ b/gui/wxpython/vnet/vnet_core.py
@@ -828,9 +828,7 @@ def _prepareCmd(self, cmd):
if c.find("=") == -1:
continue
v = c.split("=")
- if len(v) != 2:
- cmd.remove(c)
- elif not v[1].strip():
+ if len(v) != 2 or not v[1].strip():
cmd.remove(c)
def _setCmdForSpecificAn(self, cmdParams):
diff --git a/gui/wxpython/vnet/widgets.py b/gui/wxpython/vnet/widgets.py
index 12477cc93ea..ed1f2aa514c 100644
--- a/gui/wxpython/vnet/widgets.py
+++ b/gui/wxpython/vnet/widgets.py
@@ -542,7 +542,7 @@ def IsShown(self, colName) -> bool:
:return: False - if is not shown
"""
- return not self._getColumnNum(colName) == -1
+ return self._getColumnNum(colName) != -1
class EditItem(wx.Dialog):
diff --git a/gui/wxpython/wxplot/profile.py b/gui/wxpython/wxplot/profile.py
index 1d3de6681af..61efdcd67d0 100644
--- a/gui/wxpython/wxplot/profile.py
+++ b/gui/wxpython/wxplot/profile.py
@@ -20,6 +20,8 @@
import math
import numpy as np
+from pathlib import Path
+
import wx
from wx.lib import plot
@@ -410,7 +412,7 @@ def SaveProfileToFile(self, event):
dlg = wx.FileDialog(
parent=self,
message=_("Choose prefix for file(s) where to save profile values..."),
- defaultDir=os.getcwd(),
+ defaultDir=str(Path.cwd()),
wildcard=_("Comma separated value (*.csv)|*.csv"),
style=wx.FD_SAVE,
)
diff --git a/imagery/i.gensig/testsuite/test_i_gensig.py b/imagery/i.gensig/testsuite/test_i_gensig.py
index 0498cabaf79..d75e3da2af4 100644
--- a/imagery/i.gensig/testsuite/test_i_gensig.py
+++ b/imagery/i.gensig/testsuite/test_i_gensig.py
@@ -13,6 +13,7 @@
import stat
import ctypes
import shutil
+from pathlib import Path
from grass.pygrass import utils
from grass.pygrass.gis import Mapset
@@ -107,7 +108,7 @@ def test_creation(self):
)
# File must be present
- sig_stat = os.stat(f"{self.sig_dir1}/sig")
+ sig_stat = Path(self.sig_dir1, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
# Compare values within sig file
diff --git a/lib/imagery/testsuite/test_imagery_sigfile.py b/lib/imagery/testsuite/test_imagery_sigfile.py
index 104cd5a59b4..8d0e288561d 100644
--- a/lib/imagery/testsuite/test_imagery_sigfile.py
+++ b/lib/imagery/testsuite/test_imagery_sigfile.py
@@ -9,10 +9,10 @@
for details
"""
-import os
import stat
import ctypes
import shutil
+from pathlib import Path
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
@@ -80,7 +80,7 @@ def test_roundtrip_signature_v1_norgb_one_label(self):
# Write signatures to file
p_new_sigfile = I_fopen_signature_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_write_signatures(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
@@ -136,7 +136,7 @@ def test_broken_signature_v1_norgb(self):
# Write signatures to file
p_new_sigfile = I_fopen_signature_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_write_signatures(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
@@ -188,7 +188,7 @@ def test_roundtrip_signature_v1_norgb_two_labelss(self):
# Write signatures to file
p_new_sigfile = I_fopen_signature_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_write_signatures(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
@@ -277,7 +277,7 @@ def test_roundtrip_signature_v2_norgb_two_labels_oclass(self):
# Write signatures to file
p_new_sigfile = I_fopen_signature_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_write_signatures(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
diff --git a/lib/imagery/testsuite/test_imagery_sigsetfile.py b/lib/imagery/testsuite/test_imagery_sigsetfile.py
index b8bcb566520..d526e920885 100644
--- a/lib/imagery/testsuite/test_imagery_sigsetfile.py
+++ b/lib/imagery/testsuite/test_imagery_sigsetfile.py
@@ -9,10 +9,10 @@
for details
"""
-import os
import stat
import ctypes
import shutil
+from pathlib import Path
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
@@ -84,7 +84,7 @@ def test_roundtrip_sigset_v1_one_label(self):
# Write signatures to file
p_new_sigfile = I_fopen_sigset_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_WriteSigSet(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
@@ -139,7 +139,7 @@ def test_read_fail_sigset_v1_one_label(self):
# Write signatures to file
p_new_sigfile = I_fopen_sigset_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_WriteSigSet(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
@@ -183,7 +183,7 @@ def test_roundtrip_sigset_v1_two_labels(self):
# Write signatures to file
p_new_sigfile = I_fopen_sigset_file_new(self.sig_name)
- sig_stat = os.stat(f"{self.sig_dir}/sig")
+ sig_stat = Path(self.sig_dir, "sig").stat()
self.assertTrue(stat.S_ISREG(sig_stat.st_mode))
I_WriteSigSet(p_new_sigfile, ctypes.byref(So))
self.libc.fclose(p_new_sigfile)
diff --git a/lib/init/grass.py b/lib/init/grass.py
index 40312471e44..25486d9426c 100755
--- a/lib/init/grass.py
+++ b/lib/init/grass.py
@@ -400,7 +400,7 @@ def create_grass_config_dir():
os.makedirs(directory)
except OSError as e:
# Can happen as a race condition
- if not e.errno == errno.EEXIST or not os.path.isdir(directory):
+ if e.errno != errno.EEXIST or not os.path.isdir(directory):
fatal(
_(
"Failed to create configuration directory '{}' with error: {}"
@@ -620,7 +620,7 @@ def create_initial_gisrc(filename):
LOCATION_NAME: