Browse Source

pygrass: don't crash when mapset has no elements

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32333 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 năm trước cách đây
mục cha
commit
c283f3434c
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      lib/python/grass.py

+ 3 - 1
lib/python/grass.py

@@ -159,6 +159,7 @@ def list_grouped(type):
     dashes_re = re.compile("^----+$")
     mapset_re = re.compile("<(.*)>:$")
     result = {}
+    mapset = None
     for line in read_command("g.list", type = type).splitlines():
 	if line == "":
 	    continue
@@ -169,7 +170,8 @@ def list_grouped(type):
 	    mapset = m.group(1)
 	    result[mapset] = []
 	    continue
-	result[mapset].extend(line.split())
+        if mapset:
+            result[mapset].extend(line.split())
     return result
 
 def _concat(xs):