浏览代码

pythonlib: improve mapsets() interface

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48755 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 年之前
父节点
当前提交
51b7e5c58a
共有 3 个文件被更改,包括 10 次插入10 次删除
  1. 1 1
      gui/wxpython/gui_modules/gselect.py
  2. 8 8
      lib/python/core.py
  3. 1 1
      lib/python/db.py

+ 1 - 1
gui/wxpython/gui_modules/gselect.py

@@ -329,7 +329,7 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
         
         # list of mapsets in current location
         if mapsets is None:
-            mapsets = grass.mapsets()
+            mapsets = grass.mapsets(searchPath = True)
         
         # current mapset first
         if curr_mapset in mapsets and mapsets[0] != curr_mapset:

+ 8 - 8
lib/python/core.py

@@ -629,7 +629,7 @@ def list_grouped(type, check_search_path = True):
     mapset_re = re.compile("<(.*)>")
     result = {}
     if check_search_path:
-        for mapset in mapsets(accessible = True):
+        for mapset in mapsets(searchPath = True):
             result[mapset] = []
     
     mapset = None
@@ -712,7 +712,7 @@ def mlist_grouped(type, pattern = None, check_search_path = True):
     """
     result = {}
     if check_search_path:
-        for mapset in mapsets(accessible = True):
+        for mapset in mapsets(searchPath = True):
             result[mapset] = []
     
     mapset = None
@@ -875,14 +875,14 @@ def float_or_dms(s):
 
 # interface to g.mapsets
 
-def mapsets(accessible = True):
-    """!List accessible mapsets (mapsets in search path)
-
-    @param accessible False to list all mapsets in the location
+def mapsets(searchPath = False):
+    """!List available mapsets
 
+    @param searchPatch True to list mapsets only in search path
+    
     @return list of mapsets
     """
-    if accessible:
+    if searchPath:
         flags = 'p'
     else:
         flags = 'l'
@@ -892,7 +892,7 @@ def mapsets(accessible = True):
                            quiet = True)
     if not mapsets:
         fatal(_("Unable to list mapsets"))
-        
+    
     return mapsets.splitlines()
 
 # interface to `g.proj -c`

+ 1 - 1
lib/python/db.py

@@ -122,7 +122,7 @@ def db_select(table, sql, file = False, **args):
         fatal(_("Fetching data from table <%s> failed") % table)
 
     ofile = open(fname)
-    result = ofile.readlines()
+    result = map(lambda x: x.rstrip(os.linesep), ofile.readlines())
     ofile.close()
     try_remove(fname)