Skip to content

Commit

Permalink
Merge branch 'main' into ruff-format-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Feb 5, 2025
2 parents b8da354 + def6697 commit 7b0a740
Show file tree
Hide file tree
Showing 80 changed files with 1,868 additions and 1,821 deletions.
7 changes: 5 additions & 2 deletions display/d.vect.chart/plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ int plot(int ctype, struct Map_info *Map, int type, int field, char *columns,
dbTable *table;
dbColumn *column;

Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
db_init_string(&sql);

Fi = Vect_get_field(Map, field);
Expand All @@ -40,8 +38,11 @@ int plot(int ctype, struct Map_info *Map, int type, int field, char *columns,
if (driver == NULL) {
G_warning(_("Unable to open database <%s> by driver <%s>"),
Fi->database, Fi->driver);
Vect_destroy_field_info(Fi);
return 1;
}
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
db_set_error_handler_driver(driver);

val =
Expand Down Expand Up @@ -134,6 +135,8 @@ int plot(int ctype, struct Map_info *Map, int type, int field, char *columns,
db_close_database_shutdown_driver(driver);
Vect_destroy_line_struct(Points);
Vect_destroy_cats_struct(Cats);
Vect_destroy_field_info(Fi);
G_free(val);

return 0;
}
35 changes: 3 additions & 32 deletions general/g.setproj/g.setproj.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>g.setproj - GRASS GIS manual</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="grassdocs.css" type="text/css">
<meta http-equiv="content-language" content="en-us">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white">

<img src="grass_logo.png" alt="GRASS logo"><hr align="center" size="6" noshade>

<h2>NAME</h2>
<h2>DESCRIPTION</h2>

<em><b>g.setproj</b></em> allows the user to create the PROJ_INFO and the
<em>g.setproj</em> allows the user to create the PROJ_INFO and the
PROJ_UNITS files to record the coordinate reference system (CRS) information
associated with a current project (previously called location).
<br>

<h2>SYNOPSIS</h2>

<b>g.setproj</b>

<h2>DESCRIPTION</h2>

Allows a user to create a PROJ_INFO file in the PERMANENT mapset of the
current project. PROJ_INFO file is used to record the CRS information
associated with the specified project.

<h2>NOTES</h2>

Expand Down Expand Up @@ -82,11 +58,6 @@ <h2>SEE ALSO</h2>

<h2>AUTHORS</h2>

Irina Kosinovsky,
U.S. Army Construction Engineering
Research Laboratory<br>
Irina Kosinovsky, U.S. Army Construction Engineering Research Laboratory<br>
Morten Hulden, morten at untamo.net - rewrote module and added 121 projections <br>
Andreas Lange, andreas.lange at rhein-main.de - added prelimnary map datum support

</body>
</html>
3 changes: 2 additions & 1 deletion gui/wxpython/animation/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from grass.script.utils import parse_key_val
from grass.script import core as gcore
from grass.exceptions import ScriptError

from core.gcmd import GException
from animation.nviztask import NvizTask
Expand Down Expand Up @@ -299,7 +300,7 @@ def SetName(self, name):
try:
name = validateTimeseriesName(name, self._mapType)
self._maps = getRegisteredMaps(name, self._mapType)
except (GException, gcore.ScriptError) as e:
except (GException, ScriptError) as e:
raise ValueError(str(e))
else:
self._maps = validateMapNames(name.split(","), self._mapType)
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/animation/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from wx import HyperlinkCtrl

from core.gcmd import GMessage, GError, GException
from grass.exceptions import ScriptError
from core import globalvar
from gui_core.dialogs import MapLayersDialog, GetImageHandlers
from gui_core.preferences import PreferencesBaseDialog
Expand Down Expand Up @@ -727,10 +728,9 @@ def _update(self):
if isStart:
self.animationData.startRegion = isStart
else:
if isStart:
self.animationData.startRegion = isStart
else:
if not isStart:
raise GException(_("Region information is not complete"))
self.animationData.startRegion = isStart
if isEnd:
self.animationData.endRegion = self.endRegion.GetValue()
self.animationData.zoomRegionValue = None
Expand Down Expand Up @@ -1785,7 +1785,7 @@ def _createDefaultCommand(self):
if maps:
mapName, mapLayer = getNameAndLayer(maps[0])
cmd.append("map={name}".format(name=mapName))
except gcore.ScriptError as e:
except ScriptError as e:
GError(parent=self, message=str(e), showTraceback=False)
return None
return cmd
Expand Down Expand Up @@ -1838,7 +1838,7 @@ def _onOK(self, event):
self.layer.name = self._name
self.layer.cmd = self._cmd
event.Skip()
except (GException, gcore.ScriptError) as e:
except (GException, ScriptError) as e:
GError(parent=self, message=str(e))

def GetLayer(self):
Expand Down
6 changes: 2 additions & 4 deletions gui/wxpython/animation/nviztask.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,10 @@ def GetCommandSeries(self, layerList, paramName):

if len(layerList) > 1:
raise GException(_("Please add only one layer in the list."))
return
layer = layerList[0]
if hasattr(layer, "maps"):
series = layer.maps
else:
if not hasattr(layer, "maps"):
raise GException(_("No map series nor space-time dataset is added."))
series = layer.maps

for value in series:
self.task.set_param(paramName, value)
Expand Down
17 changes: 9 additions & 8 deletions gui/wxpython/animation/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,15 @@ def Clear(self):
Debug.msg(4, "MapFilesPool.Clear")

for key in list(self.dictionary.keys()):
if self.referenceCount[key] <= 0:
name, ext = os.path.splitext(self.dictionary[key])
os.remove(self.dictionary[key])
if ext == ".ppm":
os.remove(name + ".pgm")
del self.dictionary[key]
del self.referenceCount[key]
del self.size[key]
if self.referenceCount[key] > 0:
continue
name, ext = os.path.splitext(self.dictionary[key])
os.remove(self.dictionary[key])
if ext == ".ppm":
os.remove(name + ".pgm")
del self.dictionary[key]
del self.referenceCount[key]
del self.size[key]


class BitmapPool(DictRefCounter):
Expand Down
53 changes: 27 additions & 26 deletions gui/wxpython/animation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,18 @@ def validateMapNames(names, etype):
for name in names:
if name.find("@") >= 0:
nameShort, mapset = name.split("@", 1)
if nameShort in mapDict[mapset]:
newNames.append(name)
else:
raise GException(_("Map <%s> not found.") % name)
else:
found = False
for mapset, mapNames in mapDict.items():
if name in mapNames:
found = True
newNames.append(name + "@" + mapset)
if not found:
if nameShort not in mapDict[mapset]:
raise GException(_("Map <%s> not found.") % name)
newNames.append(name)

continue
found = False
for mapset, mapNames in mapDict.items():
if name in mapNames:
found = True
newNames.append(name + "@" + mapset)
if not found:
raise GException(_("Map <%s> not found.") % name)
return newNames


Expand Down Expand Up @@ -331,21 +331,22 @@ def layerListToCmdsMatrix(layerList):
continue
if hasattr(layer, "maps"):
for i, part in enumerate(layer.cmd):
if part.startswith("map="):
cmd = layer.cmd[:]
cmds = []
for map_ in layer.maps:
# check if dataset uses layers instead of maps
mapName, mapLayer = getNameAndLayer(map_)
cmd[i] = "map={name}".format(name=mapName)
if mapLayer:
try:
idx = cmd.index("layer")
cmd[idx] = "layer={layer}".format(layer=mapLayer)
except ValueError:
cmd.append("layer={layer}".format(layer=mapLayer))
cmds.append(cmd[:])
cmdsForComposition.append(cmds)
if not part.startswith("map="):
continue
cmd = layer.cmd[:]
cmds = []
for map_ in layer.maps:
# check if dataset uses layers instead of maps
mapName, mapLayer = getNameAndLayer(map_)
cmd[i] = "map={name}".format(name=mapName)
if mapLayer:
try:
idx = cmd.index("layer")
cmd[idx] = "layer={layer}".format(layer=mapLayer)
except ValueError:
cmd.append("layer={layer}".format(layer=mapLayer))
cmds.append(cmd[:])
cmdsForComposition.append(cmds)
else:
cmdsForComposition.append([layer.cmd] * count)

Expand Down
38 changes: 19 additions & 19 deletions gui/wxpython/core/gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,25 @@ def __init__(self, args, **kwargs):
# "^" must be the first character in the list to avoid double
# escaping.
for c in ("^", "|", "&", "<", ">"):
if c in args[i]:
if "=" in args[i]:
a = args[i].split("=")
k = a[0] + "="
v = "=".join(a[1 : len(a)])
else:
k = ""
v = args[i]

# If there are spaces, the argument was already
# esscaped with double quotes, so don't escape it
# again.
if c in v and " " not in v:
# Here, we escape each ^ in ^^^ with ^^ and a
# <special character> with ^ + <special character>,
# so we need 7 carets.

v = v.replace(c, "^^^^^^^" + c)
args[i] = k + v
if c not in args[i]:
continue
if "=" in args[i]:
a = args[i].split("=")
k = a[0] + "="
v = "=".join(a[1 : len(a)])
else:
k = ""
v = args[i]

# If there are spaces, the argument was already
# escaped with double quotes, so don't escape it
# again.
if c in v and " " not in v:
# Here, we escape each ^ in ^^^ with ^^ and a
# <special character> with ^ + <special character>,
# so we need 7 carets.
v = v.replace(c, "^^^^^^^" + c)
args[i] = k + v

subprocess.Popen.__init__(self, args, **kwargs)

Expand Down
4 changes: 3 additions & 1 deletion gui/wxpython/core/globalvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from grass.script.core import get_commands

from core.debug import Debug
from pathlib import Path

# path to python scripts
ETCDIR = os.path.join(os.getenv("GISBASE"), "etc")
Expand Down Expand Up @@ -206,7 +207,8 @@ def UpdateGRASSAddOnCommands(eList=None):
if pathList and path not in pathList:
os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]

for fname in os.listdir(path):
for file_path in Path(path).iterdir():
fname = file_path.name
if fname in {"docs", "modules.xml"}:
continue
if grassScripts: # win32
Expand Down
Loading

0 comments on commit 7b0a740

Please sign in to comment.