Skip to content

Commit

Permalink
python: Partial reverts to still have empty lists in certain situatio…
Browse files Browse the repository at this point in the history
…ns, solve #5013 (#5018)
  • Loading branch information
echoix authored Feb 4, 2025
1 parent 9ad5047 commit 5293516
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
12 changes: 9 additions & 3 deletions gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2408,9 +2408,15 @@ def OnCheckItem(index=None, flag=None, event=None):
pSqlWhere.append(p)

# collect ids
pColumnIds = [p["wxId"] for p in pColumn]
pLayerIds = [p["wxId"] for p in pLayer]
pSqlWhereIds = [p["wxId"] for p in pSqlWhere]
pColumnIds = []
for p in pColumn:
pColumnIds += p["wxId"]
pLayerIds = []
for p in pLayer:
pLayerIds += p["wxId"]
pSqlWhereIds = []
for p in pSqlWhere:
pSqlWhereIds += p["wxId"]

# set wxId-bindings
if pMap:
Expand Down
25 changes: 16 additions & 9 deletions python/grass/grassdb/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import grass.grassdb.config as cfg
import grass.script as gs
from grass.script import gisenv
from itertools import starmap


def mapset_exists(path: str | os.PathLike[str], location=None, mapset=None) -> bool:
Expand Down Expand Up @@ -525,7 +524,10 @@ def get_reasons_locations_not_removable(locations):
Returns messages as list if there were any failed checks, otherwise empty list.
"""
return list(starmap(get_reasons_location_not_removable, locations))
messages = []
for grassdb, location in locations:
messages += get_reasons_location_not_removable(grassdb, location)
return messages


def get_reasons_location_not_removable(grassdb, location):
Expand Down Expand Up @@ -556,7 +558,9 @@ def get_reasons_location_not_removable(grassdb, location):
)

# Append to the list of tuples
mapsets = [(grassdb, location, g_mapset) for g_mapset in g_mapsets]
mapsets = []
for g_mapset in g_mapsets:
mapsets.append((grassdb, location, g_mapset))

# Concentenate both checks
messages += get_reasons_mapsets_not_removable(mapsets, check_permanent=False)
Expand Down Expand Up @@ -585,7 +589,9 @@ def get_reasons_grassdb_not_removable(grassdb):
g_locations = get_list_of_locations(grassdb)

# Append to the list of tuples
locations = [(grassdb, g_location) for g_location in g_locations]
locations = []
for g_location in g_locations:
locations.append((grassdb, g_location))
return get_reasons_locations_not_removable(locations)


Expand All @@ -596,11 +602,12 @@ def get_list_of_locations(dbase):
:return: list of locations (sorted)
"""
locations = [
os.path.basename(location)
for location in glob.glob(os.path.join(dbase, "*"))
if os.path.join(location, "PERMANENT") in glob.glob(os.path.join(location, "*"))
]
locations = []
for location in glob.glob(os.path.join(dbase, "*")):
if os.path.join(location, "PERMANENT") in glob.glob(
os.path.join(location, "*")
):
locations.append(os.path.basename(location))

locations.sort(key=lambda x: x.lower())

Expand Down

0 comments on commit 5293516

Please sign in to comment.