Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into typing-rpc-server
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Nov 2, 2024
2 parents dcbfb14 + 0824e88 commit 90147d7
Show file tree
Hide file tree
Showing 39 changed files with 200 additions and 156 deletions.
14 changes: 4 additions & 10 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ per-file-ignores =
doc/python/m.distance.py: E501
gui/scripts/d.wms.py: E501
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/nviz/*: E722
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: E501, E722
gui/wxpython/vdigit/*: F841, E722, F405, F403
Expand Down Expand Up @@ -89,18 +88,13 @@ per-file-ignores =
python/grass/*/*/__init__.py: F403
python/grass/*/*/*/__init__.py: F403
# E402 module level import not at top of file
scripts/r.in.wms/wms_gdal_drv.py: E722
scripts/r.in.wms/wms_drv.py: E402, E722
scripts/r.in.wms/srs.py: E722
scripts/r.semantic.label/r.semantic.label.py: E501
scripts/v.report/v.report.py: E721
scripts/db.out.ogr/db.out.ogr.py: F841
scripts/g.extension/g.extension.py: F841, E722, E501
scripts/v.unpack/v.unpack.py: E722, E501
scripts/v.import/v.import.py: E722, E501
scripts/g.extension/g.extension.py: E501
scripts/v.unpack/v.unpack.py: E501n
scripts/v.import/v.import.py: E501
scripts/db.univar/db.univar.py: E501
scripts/d.frame/d.frame.py: E722
scripts/i.pansharpen/i.pansharpen.py: E722, E501
scripts/i.pansharpen/i.pansharpen.py: E501
scripts/v.what.strds/v.what.strds.py: E501
# Line too long (esp. module interface definitions)
scripts/*/*.py: E501
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
sha256sum ${{ env.GRASS }}.tar.xz > ${{ env.GRASS }}.tar.xz.sha256
- name: Publish draft distribution to GitHub (for tags only)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
with:
name: GRASS GIS ${{ github.ref_name }}
body: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# renovate: datasource=pypi depName=bandit
BANDIT_VERSION: "1.7.10"
# renovate: datasource=pypi depName=ruff
RUFF_VERSION: "0.7.1"
RUFF_VERSION: "0.7.2"

runs-on: ${{ matrix.os }}
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.1
rev: v0.7.2
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.10@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5
# syntax=docker/dockerfile:1.11@sha256:1f2be5a2aa052cbd9aedf893d17c63277c3d1c51b3fb0f3b029c6b34f658d057

# Note: This file must be kept in sync in ./Dockerfile and ./docker/ubuntu/Dockerfile.
# Changes to this file must be copied over to the other file.
Expand Down
2 changes: 1 addition & 1 deletion docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.10@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5
# syntax=docker/dockerfile:1.11@sha256:1f2be5a2aa052cbd9aedf893d17c63277c3d1c51b3fb0f3b029c6b34f658d057

# Note: This file must be kept in sync in ./Dockerfile and ./docker/ubuntu/Dockerfile.
# Changes to this file must be copied over to the other file.
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gui/wxpython/nviz/mapwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def LoadDataLayers(self):
GError(parent=self, message=e.value)
# when nviz.tools is not yet ready
# during opening 3D view 2nd time
except:
except Exception:
pass

stop = gs.clock()
Expand Down
62 changes: 18 additions & 44 deletions gui/wxpython/nviz/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def SetInitialMaps(self):
else:
try:
selection = layers[0].GetName()
except:
except (AttributeError, IndexError):
continue
if ltype == "raster":
self.FindWindowById(self.win["surface"]["map"]).SetValue(selection)
Expand Down Expand Up @@ -734,24 +734,11 @@ def _createDataPage(self):
self.mainPanelData = SP.ScrolledPanel(parent=self)
self.mainPanelData.SetupScrolling(scroll_x=False)
self.mainPanelData.AlwaysShowScrollbars(hflag=False)
try: # wxpython <= 2.8.10
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
style=fpb.FPB_DEFAULT_STYLE,
extraStyle=fpb.FPB_SINGLE_FOLD,
)
except:
try: # wxpython >= 2.8.11
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)
except: # to be sure
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData, id=wx.ID_ANY, style=fpb.FPB_SINGLE_FOLD
)
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)

self.foldpanelData.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)

Expand Down Expand Up @@ -814,24 +801,11 @@ def _createAppearancePage(self):
self.mainPanelAppear = SP.ScrolledPanel(parent=self)
self.mainPanelAppear.SetupScrolling(scroll_x=False)
self.mainPanelAppear.AlwaysShowScrollbars(hflag=False)
try: # wxpython <= 2.8.10
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
style=fpb.FPB_DEFAULT_STYLE,
extraStyle=fpb.FPB_SINGLE_FOLD,
)
except:
try: # wxpython >= 2.8.11
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)
except: # to be sure
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear, id=wx.ID_ANY, style=fpb.FPB_SINGLE_FOLD
)
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)

self.foldpanelAppear.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
# light page
Expand Down Expand Up @@ -3360,7 +3334,7 @@ def OnSetSurface(self, event):
name = event.GetString()
try:
self._getLayerPropertiesByName(name, mapType="raster")["surface"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("fringe", False)
return

Expand All @@ -3384,7 +3358,7 @@ def OnSetVector(self, event):
name = event.GetString()
try:
data = self._getLayerPropertiesByName(name, mapType="vector")["vector"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("vector", False)
return
layer = self._getMapLayerByName(name, mapType="vector")
Expand All @@ -3396,7 +3370,7 @@ def OnSetRaster3D(self, event):
name = event.GetString()
try:
data = self._getLayerPropertiesByName(name, mapType="raster_3d")["volume"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("volume", False)
return

Expand Down Expand Up @@ -4925,7 +4899,7 @@ def OnCPlaneSelection(self, event):
try:
planeIndex = int(plane.split()[-1]) - 1
self.EnablePage("cplane", enabled=True)
except:
except (ValueError, IndexError):
planeIndex = -1
self.EnablePage("cplane", enabled=False)
self.mapWindow.SelectCPlane(planeIndex)
Expand All @@ -4942,7 +4916,7 @@ def OnCPlaneChanging(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

if event.GetId() in (
Expand Down Expand Up @@ -4984,7 +4958,7 @@ def OnCPlaneShading(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

self.mapWindow.cplanes[planeIndex]["shading"] = shading
Expand All @@ -4999,7 +4973,7 @@ def OnCPlaneReset(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

self.mapWindow.cplanes[planeIndex] = copy.deepcopy(
Expand Down
10 changes: 10 additions & 0 deletions gui/wxpython/nviz/wxnviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
CONST_ATT,
DM_FLAT,
DM_GOURAUD,
DM_GRID_SURF,
DM_GRID_WIRE,
DM_POLY,
DM_WIRE,
DM_WIRE_POLY,
MAP_ATT,
MAX_ISOSURFS,
GP_delete_site,
Expand Down Expand Up @@ -2442,6 +2447,11 @@ def Corresponds(self, item):
__all__ = [
"DM_FLAT",
"DM_GOURAUD",
"DM_GRID_SURF",
"DM_GRID_WIRE",
"DM_POLY",
"DM_WIRE",
"DM_WIRE_POLY",
"DRAW_QUICK_SURFACE",
"DRAW_QUICK_VLINES",
"DRAW_QUICK_VOLUME",
Expand Down
1 change: 1 addition & 0 deletions include/grass/defs/raster.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ int Rast_option_to_interp_type(const struct Option *);

/* mask_info.c */
char *Rast_mask_info(void);
char *Rast_mask_name(void);
bool Rast_mask_status(char *, char *, bool *, char *, char *);
int Rast__mask_info(char *, char *);
bool Rast_mask_is_present(void);
Expand Down
1 change: 1 addition & 0 deletions lib/gis/colors.desc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sepia: yellowish-brown through to white
slope: r.slope.aspect-type slope colors for raster values 0-90
soilmoisture: soilmoisture color table (0.0-1.0)
srtm: color palette for Shuttle Radar Topography Mission elevation
srtm_percent: color palette for Shuttle Radar Topography Mission using relative elevation
srtm_plus: color palette for Shuttle Radar Topography Mission elevation (with seafloor colors)
terrain: global elevation color table covering -11000 to +8850m
viridis: perceptually uniform sequential color table viridis
Expand Down
7 changes: 7 additions & 0 deletions lib/gis/colors/srtm_percent
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
0% 57 151 105
25% 117 194 93
40% 230 230 128
55% 214 187 98
70% 185 154 100
80% 150 120 80
100% 220 220 220
4 changes: 3 additions & 1 deletion lib/gis/copy_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ int G_recursive_copy(const char *src, const char *dst)
sprintf(path, "%s/%s", src, dp->d_name);
sprintf(path2, "%s/%s", dst, dp->d_name);

if (G_recursive_copy(path, path2) != 0)
if (G_recursive_copy(path, path2) != 0) {
closedir(dirp);
return 1;
}
}

closedir(dirp);
Expand Down
12 changes: 9 additions & 3 deletions lib/ogsf/gvl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,16 @@ void GVL_get_dims(int id, int *rows, int *cols, int *depths)
*rows = gvl->rows;
*cols = gvl->cols;
*depths = gvl->depths;
}

G_debug(3, "GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d",
gvl->gvol_id, gvl->rows, gvl->cols, gvl->depths);
G_debug(3, "GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d",
gvl->gvol_id, gvl->rows, gvl->cols, gvl->depths);
}
else {
G_debug(2,
"GVL_get_dims(): Attempted to access a null volume structure "
"for id=%d",
id);
}

return;
}
Expand Down
21 changes: 21 additions & 0 deletions lib/raster/mask_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ char *Rast_mask_info(void)
return G_store(text);
}

/**
* @brief Retrieves the name of the raster mask to use.
*
* The returned raster map name is fully qualified, i.e., in the form
% "name@mapset".
*
* The mask name is "MASK@<mapset>", where <mapset> is the current
* mapset.
*
* The memory for the returned mask name is dynamically allocated using
* G_store(). It is the caller's responsibility to free the memory with
* G_free() when it is no longer needed.
*
* @returns A dynamically allocated string containing the mask name.
*/
char *Rast_mask_name(void)
{
// Mask name is always "MASK@<current mapset>".
return G_fully_qualified_name("MASK", G_mapset());
}

/**
* @brief Get raster mask status information
*
Expand Down
10 changes: 6 additions & 4 deletions python/grass/script/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ def list_strings(type, pattern=None, mapset=None, exclude=None, flag="", env=Non
:return: list of elements
"""
if type == "cell":
verbose(_('Element type should be "raster" and not "%s"') % type)
verbose(_('Element type should be "raster" and not "%s"') % type, env=env)

result = []
for line in read_command(
Expand Down Expand Up @@ -1520,7 +1520,9 @@ def list_grouped(
flag += "t"
for i in range(len(types)):
if types[i] == "cell":
verbose(_('Element type should be "raster" and not "%s"') % types[i])
verbose(
_('Element type should be "raster" and not "%s"') % types[i], env=env
)
types[i] = "raster"
result = {}
if check_search_path:
Expand All @@ -1543,7 +1545,7 @@ def list_grouped(
try:
name, mapset = line.split("@")
except ValueError:
warning(_("Invalid element '%s'") % line)
warning(_("Invalid element '%s'") % line, env=env)
continue

if store_types:
Expand Down Expand Up @@ -1701,7 +1703,7 @@ def mapsets(search_path=False, env=None):
flags = "p" if search_path else "l"
mapsets = read_command("g.mapsets", flags=flags, sep="newline", quiet=True, env=env)
if not mapsets:
fatal(_("Unable to list mapsets"))
fatal(_("Unable to list mapsets"), env=env)

return mapsets.splitlines()

Expand Down
7 changes: 4 additions & 3 deletions python/grass/script/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def db_describe(table, env=None, **args):
args.pop("driver")
s = read_command("db.describe", flags="c", table=table, env=env, **args)
if not s:
fatal(_("Unable to describe table <%s>") % table)
fatal(_("Unable to describe table <%s>") % table, env=env)

cols = []
result = {}
Expand Down Expand Up @@ -179,7 +179,8 @@ def db_select(sql=None, filename=None, table=None, env=None, **args):
"Programmer error: '%(sql)s', '%(filename)s', or '%(table)s' must be \
provided"
)
% {"sql": "sql", "filename": "filename", "table": "table"}
% {"sql": "sql", "filename": "filename", "table": "table"},
env=env,
)

if "sep" not in args:
Expand All @@ -188,7 +189,7 @@ def db_select(sql=None, filename=None, table=None, env=None, **args):
try:
run_command("db.select", quiet=True, flags="c", output=fname, env=env, **args)
except CalledModuleError:
fatal(_("Fetching data failed"))
fatal(_("Fetching data failed"), env=env)

ofile = open(fname)
result = [tuple(x.rstrip(os.linesep).split(args["sep"])) for x in ofile]
Expand Down
Loading

0 comments on commit 90147d7

Please sign in to comment.