[GRASS-SVN] r30236 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 18 10:49:35 EST 2008


Author: martinl
Date: 2008-02-18 10:49:35 -0500 (Mon, 18 Feb 2008)
New Revision: 30236

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: define fn for list sorting (not case-sensitive), sort mapset names

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2008-02-18 15:26:31 UTC (rev 30235)
+++ grass/trunk/gui/wxpython/gis_set.py	2008-02-18 15:49:35 UTC (rev 30236)
@@ -504,9 +504,9 @@
                     self.listOfLocations.append(os.path.basename(location))
             except:
                 pass
-            
-        self.listOfLocations.sort(cmp=lambda x,y: cmp(x.lower(), y.lower()))
 
+        utils.ListSortLower(self.listOfLocations)
+
         self.lblocations.Clear()
         self.lblocations.InsertItems(self.listOfLocations, 0)
 
@@ -520,7 +520,7 @@
             if os.path.isdir(mapset) and os.path.basename(mapset) != 'PERMANENT':
                 self.listOfMapsets.append(os.path.basename(mapset))
         
-        self.listOfMapsets.sort(cmp=lambda x,y: cmp(x.lower(), y.lower()))
+        utils.ListSortLower(self.listOfMapsets)
         self.listOfMapsets.insert(0,'PERMANENT')
  
         self.lbmapsets.Clear()

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-02-18 15:26:31 UTC (rev 30235)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-02-18 15:49:35 UTC (rev 30236)
@@ -155,8 +155,10 @@
     
     try:
         # for mset in cmd.ReadStdOutput()[0].split(' '):
-        for mset in cmd.stdout.readlines()[0].strip('%s' % os.linesep).split(' '):
-            if len(mset) > 0:
+        for line in cmd.stdout.readlines():
+            for mset in line.strip('%s' % os.linesep).split(' '):
+                if len(mset) == 0:
+                    continue
                 all_mapsets.append(mset)
     except:
         raise gcmd.CmdError('Unable to get list of available mapsets.')
@@ -166,10 +168,19 @@
                            stdout=subprocess.PIPE)
     try:
         # for mset in cmd.ReadStdOutput()[0].split(' '):
-        for mset in cmd.stdout.readlines()[0].strip('%s' % os.linesep).split(' '):
-            if len(mset) > 0:
+        for line in cmd.stdout.readlines():
+            for mset in line.strip('%s' % os.linesep).split(' '):
+                if len(mset) == 0:
+                    continue
                 accessible_mapsets.append(mset)
     except:
         raise gcmd.CmdError('Unable to get list of accessible mapsets.')
 
+    ListSortLower(all_mapsets)
+    
     return (all_mapsets, accessible_mapsets)
+
+def ListSortLower(list):
+    """Sort list items (not case-sensitive)"""
+    list.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
+    



More information about the grass-commit mailing list