Skip to content

Commit

Permalink
Merge branch 'main' into markdown_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
landam authored Nov 10, 2024
2 parents 9be5d69 + 8c4f244 commit f59b0db
Show file tree
Hide file tree
Showing 63 changed files with 1,275 additions and 987 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ per-file-ignores =
gui/scripts/d.wms.py: E501
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: E501, E722
gui/wxpython/psmap/*: E501
gui/wxpython/vdigit/*: F841, E722, F405, F403
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/tplot/frame.py: F841, E722
Expand Down Expand Up @@ -75,7 +75,6 @@ per-file-ignores =
python/grass/temporal/temporal_algebra.py: E722
python/grass/temporal/temporal_granularity.py: E722
python/grass/temporal/temporal_raster_base_algebra.py: E722
python/grass/temporal/temporal_topology_dataset_connector.py: E722
# Current benchmarks/tests are changing sys.path before import.
# Possibly, a different approach should be taken there anyway.
python/grass/pygrass/tests/benchmark.py: E402, F821
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@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
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@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
category: "/language:${{matrix.language}}"
3 changes: 2 additions & 1 deletion .github/workflows/create_release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ jobs:
run: |
cd ..
tar -cvf ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar \
--exclude=".gi*" --exclude=".tr*" grass
--exclude=".gi*" --exclude=".tr*" \
--transform s/grass/${{ env.GRASS }}/ grass
cd ${{ env.OUT_DIR }}
gzip -9k ${{ env.GRASS }}.tar
md5sum ${{ env.GRASS }}.tar.gz > ${{ env.GRASS }}.tar.gz.md5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
# Year and week of year so cache key changes weekly
run: echo "date=$(date +%Y-%U)" >> "${GITHUB_OUTPUT}"
- name: Setup Mamba
uses: mamba-org/setup-micromamba@617811f69075e3fd3ae68ca64220ad065877f246 # v2.0.0
uses: mamba-org/setup-micromamba@ab6bf8bf7403e8023a094abeec19d6753bdc143e # v2.0.1
with:
init-shell: bash
environment-file: .github/workflows/macos_dependencies.txt
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 @@ -135,7 +135,7 @@ jobs:
path: bandit.sarif

- name: Upload SARIF File into Security Tab
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/upload-sarif@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
sarif_file: bandit.sarif

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.11@sha256:1f2be5a2aa052cbd9aedf893d17c63277c3d1c51b3fb0f3b029c6b34f658d057
# syntax=docker/dockerfile:1.11@sha256:10c699f1b6c8bdc8f6b4ce8974855dd8542f1768c26eb240237b8f1c9c6c9976

# 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.11@sha256:1f2be5a2aa052cbd9aedf893d17c63277c3d1c51b3fb0f3b029c6b34f658d057
# syntax=docker/dockerfile:1.11@sha256:10c699f1b6c8bdc8f6b4ce8974855dd8542f1768c26eb240237b8f1c9c6c9976

# 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
1 change: 1 addition & 0 deletions general/g.parser/standard_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static char *STD_OPT_STRINGS[] = {"G_OPT_UNDEFINED",
"G_OPT_F_SEP",
"G_OPT_C",
"G_OPT_CN",
"G_OPT_C_FORMAT",
"G_OPT_M_UNITS",
"G_OPT_M_DATATYPE",
"G_OPT_M_MAPSET",
Expand Down
34 changes: 20 additions & 14 deletions gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def SetId(self, id):
def run(self):
os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
while True:
variables = {
"callable": None,
"onDone": None,
"onPrepare": None,
"userData": None,
"addLayer": None,
"notification": None,
}
requestId, args, kwds = self.requestQ.get()
for key in (
"callable",
Expand All @@ -130,13 +138,11 @@ def run(self):
"notification",
):
if key in kwds:
vars()[key] = kwds[key]
variables[key] = kwds[key]
del kwds[key]
else:
vars()[key] = None

if not vars()["callable"]:
vars()["callable"] = GrassCmd
if not variables["callable"]:
variables["callable"] = GrassCmd

requestTime = time.time()

Expand All @@ -146,21 +152,21 @@ def run(self):
cmd=args[0],
time=requestTime,
pid=requestId,
onPrepare=vars()["onPrepare"],
userData=vars()["userData"],
onPrepare=variables["onPrepare"],
userData=variables["userData"],
)

wx.PostEvent(self.receiver, event)

# run command
event = wxCmdRun(
cmd=args[0], pid=requestId, notification=vars()["notification"]
cmd=args[0], pid=requestId, notification=variables["notification"]
)

wx.PostEvent(self.receiver, event)

time.sleep(0.1)
self.requestCmd = vars()["callable"](*args, **kwds)
self.requestCmd = variables["callable"](*args, **kwds)
if self._want_abort_all and self.requestCmd is not None:
self.requestCmd.abort()
if self.requestQ.empty():
Expand Down Expand Up @@ -211,7 +217,7 @@ def run(self):
"map=%s" % mapName,
"color=%s" % colorTable,
]
self.requestCmdColor = vars()["callable"](*argsColor, **kwds)
self.requestCmdColor = variables["callable"](*argsColor, **kwds)
self.resultQ.put((requestId, self.requestCmdColor.run()))

if self.receiver:
Expand All @@ -221,10 +227,10 @@ def run(self):
returncode=returncode,
time=requestTime,
pid=requestId,
onDone=vars()["onDone"],
userData=vars()["userData"],
addLayer=vars()["addLayer"],
notification=vars()["notification"],
onDone=variables["onDone"],
userData=variables["userData"],
addLayer=variables["addLayer"],
notification=variables["notification"],
)

# send event
Expand Down
18 changes: 11 additions & 7 deletions gui/wxpython/core/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,25 @@ def SetId(self, id):
gThread.requestId = id

def run(self):
variables = {
"callable": None,
"ondone": None,
"userdata": None,
"onterminate": None,
}
while True:
requestId, args, kwds = self.requestQ.get()
for key in ("callable", "ondone", "userdata", "onterminate"):
if key in kwds:
vars()[key] = kwds[key]
variables[key] = kwds[key]
del kwds[key]
else:
vars()[key] = None

ret = None
exception = None
time.sleep(0.01)

self._terminate_evt = wxThdTerminate(
onterminate=vars()["onterminate"],
onterminate=variables["onterminate"],
kwds=kwds,
args=args,
pid=requestId,
Expand All @@ -109,7 +113,7 @@ def run(self):
if self.terminate:
return

ret = vars()["callable"](*args, **kwds)
ret = variables["callable"](*args, **kwds)

if self.terminate:
return
Expand All @@ -119,12 +123,12 @@ def run(self):
self.resultQ.put((requestId, ret))

event = wxCmdDone(
ondone=vars()["ondone"],
ondone=variables["ondone"],
kwds=kwds,
args=args, # TODO expand args to kwds
ret=ret,
exception=exception,
userdata=vars()["userdata"],
userdata=variables["userdata"],
pid=requestId,
)

Expand Down
2 changes: 2 additions & 0 deletions gui/wxpython/dbmgr/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def OnCloseWindow(self, event):
if self.parent and self.parent.GetName() == "LayerManager":
# deregister ATM
self.parent.dialogs["atm"].remove(self)
# set map window focus
self.parent.GetMapDisplay().GetMapWindow().SetFocus()

if not isinstance(event, wx.CloseEvent):
self.Destroy()
Expand Down
18 changes: 4 additions & 14 deletions gui/wxpython/psmap/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,19 +1045,9 @@ def makePSFont(self, textDict):
if "Bold" in fontstyle:
weight = wx.FONTWEIGHT_BOLD

try:
fn = wx.Font(
pointSize=fontsize, family=family, style=style, weight=weight, face=face
)
except:
fn = wx.Font(
pointSize=fontsize,
family=wx.FONTFAMILY_DEFAULT,
style=wx.FONTSTYLE_NORMAL,
weight=wx.FONTWEIGHT_NORMAL,
)

return fn
return wx.Font(
pointSize=fontsize, family=family, style=style, weight=weight, faceName=face
)

def getTextExtent(self, textDict):
"""Estimates bounding rectangle of text"""
Expand All @@ -1071,7 +1061,7 @@ def getTextExtent(self, textDict):
dc.SetFont(fn)
w, h, lh = dc.GetFullMultiLineTextExtent(textDict["text"])
return (w, h)
except:
except (wx.PyAssertionError, ValueError, KeyError):
return (0, 0)

def getInitMap(self):
Expand Down
2 changes: 2 additions & 0 deletions gui/wxpython/vdigit/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,8 @@ def OnSelectMap(self, event):
# select the given map layer for editing
self.StartEditing(self.layers[selection])

wx.CallLater(100, self.MapWindow.SetFocus)

event.Skip()

def StartEditing(self, mapLayer):
Expand Down
2 changes: 1 addition & 1 deletion imagery/i.albedo/i.albedo.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2>TODO</h2>

Maybe change input requirement of MODIS to [0.0-1.0]?

<h2>References</h2>
<h2>REFERENCES</h2>

For a 2 band determination of the Aster BB Albedo see the following:
<p>
Expand Down
10 changes: 10 additions & 0 deletions imagery/i.vi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ int main(int argc, char *argv[])
else
G_fatal_error(_("Unknown color request '%s'"), style);
}
else if (!strcasecmp(viflag, "ndwi")) {
/* apply predefined NDWI color table */
const char *style = "ndwi";

if (G_find_color_rule("ndwi")) {
Rast_make_fp_colors(&colors, style, -1.0, 1.0);
}
else
G_fatal_error(_("Unknown color request '%s'"), style);
}
else {
/* Color from -1.0 to +1.0 in grey */
Rast_init_colors(&colors);
Expand Down
5 changes: 3 additions & 2 deletions include/grass/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ typedef enum {
G_OPT_F_OUTPUT, /*!< new output file */
G_OPT_F_SEP, /*!< data field separator */

G_OPT_C, /*!< color */
G_OPT_CN, /*!< color or none */
G_OPT_C, /*!< color */
G_OPT_CN, /*!< color or none */
G_OPT_C_FORMAT, /*!< set color format to rgb,hex,hsv or triplet */

G_OPT_M_UNITS, /*!< units */
G_OPT_M_DATATYPE, /*!< datatype */
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ include $(MODULE_TOPDIR)/include/Make/Vars.make

#order is relevant:
SUBDIRS = \
external \
datetime \
gis \
proj \
raster \
external \
gmath \
linkm \
driver \
Expand Down
4 changes: 2 additions & 2 deletions lib/gis/file_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ char *file_name(char *path, const char *dir, const char *element,
const char *name, const char *mapset, const char *base)
{
const char *pname = name;
char xname[GNAME_MAX] = {'\0'};

if (base && *base) {
sprintf(path, "%s", base);
}
else {
char xname[GNAME_MAX];
char xmapset[GMAPSET_MAX];
char xmapset[GMAPSET_MAX] = {'\0'};
char *location = G__location_path();

/*
Expand Down
17 changes: 17 additions & 0 deletions lib/gis/parser_standard_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
- colors
- G_OPT_C
- G_OPT_CN
- G_OPT_C_FORMAT
- misc
- G_OPT_M_DIR
Expand Down Expand Up @@ -652,6 +653,22 @@ struct Option *G_define_standard_option(int opt)
Opt->description =
_("Either a standard color name, R:G:B triplet, or \"none\"");
break;
case G_OPT_C_FORMAT:
Opt->key = "color_format";
Opt->type = TYPE_STRING;
Opt->key_desc = "name";
Opt->required = YES;
Opt->multiple = NO;
Opt->answer = "hex";
Opt->options = "rgb,hex,hsv,triplet";
Opt->label = _("Color format");
Opt->description = _("Color format for output values.");
G_asprintf(
(char **)&(Opt->descriptions), "rgb;%s;hex;%s;hsv;%s;triplet;%s",
_("output color in RGB format"), _("output color in HEX format"),
_("output color in HSV format (experimental)"),
_("output color in colon-separated RGB format"));
break;

/* misc */

Expand Down
Loading

0 comments on commit f59b0db

Please sign in to comment.