Skip to content

Commit

Permalink
Merge branch 'main' into manual_converted_markdown_files
Browse files Browse the repository at this point in the history
  • Loading branch information
neteler authored Dec 22, 2024
2 parents 9291be8 + d6dec75 commit 31c8179
Show file tree
Hide file tree
Showing 79 changed files with 496 additions and 320 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ per-file-ignores =
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: E501
gui/wxpython/vdigit/*: F841, E722, F405, F403
gui/wxpython/vdigit/*: E722, F405, F403
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/tplot/g.gui.tplot.py: E501
gui/wxpython/iclass/frame.py: F405, F403
gui/wxpython/iclass/g.gui.iclass.py: E501
gui/wxpython/iclass/statistics.py: F841, F405, F403
gui/wxpython/location_wizard/wizard.py: E722
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: ${{ matrix.language == 'c-cpp' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -81,6 +81,6 @@ jobs:
run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
path: bandit.sarif

- name: Upload SARIF File into Security Tab
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
sarif_file: bandit.sarif

Expand Down
5 changes: 2 additions & 3 deletions gui/wxpython/animation/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,8 @@ def __init__(self):
def SetName(self, name):
if not self.hidden:
if self._mapType is None:
raise ValueError(
"To set layer name, the type of layer must be specified."
)
msg = "To set layer name, the type of layer must be specified."
raise ValueError(msg)
if self._mapType in {"strds", "stvds", "str3ds"}:
try:
name = validateTimeseriesName(name, self._mapType)
Expand Down
3 changes: 2 additions & 1 deletion gui/wxpython/core/globalvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def CheckForWx():

version = parse_version_string(wx.__version__)
if version < WXPY3_MIN_VERSION:
raise ValueError("Your wxPython version is {}".format(wx.__version__))
msg = "Your wxPython version is {}".format(wx.__version__)
raise ValueError(msg)
return
except ImportError as e:
print("ERROR: wxGUI requires wxPython. {}".format(e), file=sys.stderr)
Expand Down
16 changes: 8 additions & 8 deletions gui/wxpython/core/layerlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ def SetName(self, name):
len(fullName) == 1 and self._mapType != "rgb"
): # skip checking rgb maps for now
if self._mapType is None:
raise ValueError(
"To set layer name, the type of layer must be specified."
)
msg = "To set layer name, the type of layer must be specified."
raise ValueError(msg)

res = gcore.find_file(
name=fullName, element=self._internalTypes[self._mapType]
)
if not res["mapset"]:
raise ValueError("Map <{name}> not found.".format(name=name))
msg = "Map <{name}> not found.".format(name=name)
raise ValueError(msg)
self._name = name + "@" + res["mapset"]
else:
self._name = name
Expand Down Expand Up @@ -263,7 +263,8 @@ def SetMapType(self, mapType):
:param mapType: can be 'raster', 'vector', 'raster_3d'
"""
if mapType not in self._mapTypes:
raise ValueError("Wrong map type used: {mtype}".format(mtype=mapType))
msg = "Wrong map type used: {mtype}".format(mtype=mapType)
raise ValueError(msg)

self._mapType = mapType

Expand All @@ -282,9 +283,8 @@ def SetOpacity(self, opacity):
:param float opacity: value between 0 and 1
"""
if not (0 <= opacity <= 1):
raise ValueError(
"Opacity value must be between 0 and 1, not {op}.".format(op=opacity)
)
msg = "Opacity value must be between 0 and 1, not {op}.".format(op=opacity)
raise ValueError(msg)
self._opacity = opacity

opacity = property(fget=GetOpacity, fset=SetOpacity)
Expand Down
3 changes: 2 additions & 1 deletion gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def ListOfMapsets(get="ordered"):
mapsets_ordered.append(mapset)
return mapsets_ordered

raise ValueError("Invalid value for 'get' parameter of ListOfMapsets()")
msg = "Invalid value for 'get' parameter of ListOfMapsets()"
raise ValueError(msg)


def ListSortLower(list):
Expand Down
6 changes: 4 additions & 2 deletions gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ def LoadModel(self, filename):
try:
gxmXml = ProcessModelFile(ET.parse(filename))
except Exception as e:
raise GException("{}".format(e))
msg = "{}".format(e)
raise GException(msg)

if self.canvas:
win = self.canvas.parent
Expand Down Expand Up @@ -1550,7 +1551,8 @@ def GetDisplayCmd(self):
elif self.prompt == "vector":
cmd.append("d.vect")
else:
raise GException("Unsupported display prompt: {}".format(self.prompt))
msg = "Unsupported display prompt: {}".format(self.prompt)
raise GException(msg)

cmd.append("map=" + self.value)

Expand Down
18 changes: 12 additions & 6 deletions gui/wxpython/gui_core/mapdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,23 @@ def GetProgressBar(self):

def GetMap(self):
"""Returns current map (renderer) instance"""
raise NotImplementedError("GetMap")
msg = self.GetMap.__name__
raise NotImplementedError(msg)

def GetWindow(self):
"""Returns current map window"""
raise NotImplementedError("GetWindow")
msg = self.GetWindow.__name__
raise NotImplementedError(msg)

def GetWindows(self):
"""Returns list of map windows"""
raise NotImplementedError("GetWindows")
msg = self.GetWindows.__name__
raise NotImplementedError(msg)

def GetMapToolbar(self):
"""Returns toolbar with zooming tools"""
raise NotImplementedError("GetMapToolbar")
msg = self.GetMapToolbar.__name__
raise NotImplementedError(msg)

def GetToolbar(self, name):
"""Returns toolbar if exists and is active, else None."""
Expand Down Expand Up @@ -393,7 +397,8 @@ def GetToolbarNames(self):

def AddToolbar(self):
"""Add defined toolbar to the window"""
raise NotImplementedError("AddToolbar")
msg = self.AddToolbar.__name__
raise NotImplementedError(msg)

def RemoveToolbar(self, name, destroy=False):
"""Removes defined toolbar from the window
Expand All @@ -419,7 +424,8 @@ def IsPaneShown(self, name):

def OnRender(self, event):
"""Re-render map composition (each map layer)"""
raise NotImplementedError("OnRender")
msg = self.OnRender.__name__
raise NotImplementedError(msg)

def OnEnableDisableRender(self, event):
"""Enable/disable auto-rendering map composition (each map layer)"""
Expand Down
69 changes: 44 additions & 25 deletions gui/wxpython/iclass/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,38 @@
@author Anna Kratochvilova <kratochanna gmail.com>
"""

import os
import copy
import os
import tempfile
from ctypes import byref, pointer

import wx

from ctypes import *

try:
from grass.lib.imagery import *
from grass.lib.vector import *
from grass.lib.imagery import (
I_free_group_ref,
I_free_signatures,
I_iclass_add_signature,
I_iclass_analysis,
I_iclass_create_raster,
I_iclass_free_statistics,
I_iclass_init_group,
I_iclass_init_signatures,
I_iclass_init_statistics,
I_iclass_statistics_set_nstd,
I_iclass_write_signatures,
I_init_group_ref,
I_init_signatures,
IClass_statistics,
Ref,
Signature,
)
from grass.lib.vector import (
Vect_area_alive,
Vect_get_map_box,
Vect_get_num_areas,
bound_box,
)

haveIClass = True
errMsg = ""
Expand All @@ -37,37 +58,35 @@
errMsg = _("Loading imagery lib failed.\n%s") % e

import grass.script as gs

from mapdisp import statusbar as sb
from mapdisp.main import StandaloneMapDisplayGrassInterface
from mapwin.buffered import BufferedMapWindow
from vdigit.toolbars import VDigitToolbar
from gui_core.mapdisp import DoubleMapPanel, FrameMixin
from core import globalvar
from core.gcmd import GError, GMessage, RunCommand
from core.render import Map
from core.gcmd import RunCommand, GMessage, GError
from dbmgr.vinfo import VectorDBInfo
from grass.pydispatch.signal import Signal
from gui_core.dialogs import SetOpacityDialog
from gui_core.mapdisp import DoubleMapPanel, FrameMixin
from gui_core.wrap import Menu
from dbmgr.vinfo import VectorDBInfo
from mapdisp import statusbar as sb
from mapdisp.main import StandaloneMapDisplayGrassInterface
from mapwin.buffered import BufferedMapWindow
from vdigit.toolbars import VDigitToolbar

from iclass.digit import IClassVDigitWindow, IClassVDigit
from iclass.toolbars import (
IClassMapToolbar,
IClassMiscToolbar,
IClassToolbar,
IClassMapManagerToolbar,
)
from iclass.statistics import StatisticsData
from iclass.dialogs import (
IClassCategoryManagerDialog,
IClassGroupDialog,
IClassSignatureFileDialog,
IClassExportAreasDialog,
IClassGroupDialog,
IClassMapDialog,
IClassSignatureFileDialog,
)
from iclass.digit import IClassVDigit, IClassVDigitWindow
from iclass.plots import PlotPanel

from grass.pydispatch.signal import Signal
from iclass.statistics import StatisticsData
from iclass.toolbars import (
IClassMapManagerToolbar,
IClassMapToolbar,
IClassMiscToolbar,
IClassToolbar,
)


class IClassMapPanel(DoubleMapPanel):
Expand Down
12 changes: 8 additions & 4 deletions gui/wxpython/iscatt/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,11 @@ class PolygonDrawer:

def __init__(self, ax, pol, empty_pol):
if pol.figure is None:
raise RuntimeError(
msg = (
"You must first add the polygon to a figure or canvas before defining "
"the interactor"
)
raise RuntimeError(msg)
self.ax = ax
self.canvas = pol.figure.canvas

Expand Down Expand Up @@ -912,7 +913,8 @@ class ModestImage(mi.AxesImage):

def __init__(self, minx=0.0, miny=0.0, *args, **kwargs):
if "extent" in kwargs and kwargs["extent"] is not None:
raise NotImplementedError("ModestImage does not support extents")
msg = f"{ModestImage.__name__} does not support extents"
raise NotImplementedError(msg)

self._full_res = None
self._sx, self._sy = None, None
Expand All @@ -932,12 +934,14 @@ def set_data(self, A):
self._A = A

if self._A.dtype != np.uint8 and not np.can_cast(self._A.dtype, float):
raise TypeError("Image data can not convert to float")
msg = "Image data can not convert to float"
raise TypeError(msg)

if self._A.ndim not in (2, 3) or (
self._A.ndim == 3 and self._A.shape[-1] not in (3, 4)
):
raise TypeError("Invalid dimensions for image data")
msg = "Invalid dimensions for image data"
raise TypeError(msg)

self._imcache = None
self._rgbacache = None
Expand Down
5 changes: 3 additions & 2 deletions gui/wxpython/lmgr/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,10 +1396,11 @@ def write_help():
# this is programmer's error
# can be relaxed in future
# but keep it strict unless needed otherwise
raise ValueError(
"OnChangeCWD cmd parameter must be list of"
msg = (
f"{self.OnChangeCWD.__name__} cmd parameter must be list of"
" length 1 or 2 and 'cd' as a first item"
)
raise ValueError(msg)
if cmd and len(cmd) > 2:
# this might be a user error
write_beginning(command=cmd)
Expand Down
5 changes: 3 additions & 2 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,10 +1548,11 @@ def write_help():
# this is programmer's error
# can be relaxed in future
# but keep it strict unless needed otherwise
raise ValueError(
"OnChangeCWD cmd parameter must be list of"
msg = (
f"{self.OnChangeCWD.__name__} cmd parameter must be a list of"
" length 1 or 2 and 'cd' as a first item"
)
raise ValueError(msg)
if cmd and len(cmd) > 2:
# this might be a user error
write_beginning(command=cmd)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/vdigit/mapwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def OnLeftDownUndo(self, event):
def _onLeftDown(self, event):
"""Left mouse button donw - vector digitizer various actions"""
try:
mapLayer = self.toolbar.GetLayer().GetName()
self.toolbar.GetLayer().GetName()
except:
GMessage(parent=self, message=_("No vector map selected for editing."))
event.Skip()
Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/vdigit/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ def _createAttributesPage(self, notebook):
# settings
flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3)
flexSizer.AddGrowableCol(0)
settings = ((_("Layer"), 1), (_("Category"), 1), (_("Mode"), _("Next to use")))
# layer
text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Layer"))
self.layer = SpinCtrl(parent=panel, id=wx.ID_ANY, min=1, max=1e3)
Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/vdigit/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ def OnHelp(self, event):

def OnAdditionalToolMenu(self, event):
"""Menu for additional tools"""
point = wx.GetMousePosition()
toolMenu = Menu()

for label, itype, handler, desc in (
Expand Down
6 changes: 0 additions & 6 deletions gui/wxpython/vdigit/wxdigit.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,6 @@ def _breakLineAtIntersection(self, line, pointsLine):
if Vect_read_line(self.poMapInfo, self.poPoints, None, line) < 0:
self._error.ReadLine(line)
return -1
points = self.poPoints
else:
points = pointsLine

listLine = Vect_new_boxlist(0)
listRef = Vect_new_list()
Expand Down Expand Up @@ -1095,7 +1092,6 @@ def EditLine(self, line, coords):
self.poMapInfo, line, ltype, self.poPoints, self.poCats
)
if newline > 0 and self.emit_signals:
new_geom = [self._getBbox(newline)]
new_areas_cats = [self._getLineAreasCategories(newline)]

if newline > 0 and self._settings["breakLines"]:
Expand Down Expand Up @@ -1124,8 +1120,6 @@ def FlipLine(self):
if not self._checkMap():
return -1

nlines = Vect_get_num_lines(self.poMapInfo)

poList = self._display.GetSelectedIList()
ret = Vedit_flip_lines(self.poMapInfo, poList)
Vect_destroy_list(poList)
Expand Down
Loading

0 comments on commit 31c8179

Please sign in to comment.