浏览代码

Sort the mapset correctly, make the current mapset the first one

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60026 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 11 年之前
父节点
当前提交
7cc62089cf
共有 1 个文件被更改,包括 44 次插入39 次删除
  1. 44 39
      temporal/t.list/t.list.py

+ 44 - 39
temporal/t.list/t.list.py

@@ -111,46 +111,51 @@ def main():
             time = "relative time"
             time = "relative time"
 
 
         stds_list = tgis.get_dataset_list(type,  ttype,  columns,  where,  order)
         stds_list = tgis.get_dataset_list(type,  ttype,  columns,  where,  order)
-    
+
+        # Use the correct order of the mapsets, hence first the current mapset, then
+        # alphabetic ordering
+        mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
+
         # Print for each mapset separately
         # Print for each mapset separately
-        for key in stds_list.keys():
-            rows = stds_list[key]
-
-            if rows:
-                if issubclass(sp.__class__,  tgis.AbstractMapDataset):
-                    sys.stderr.write(_("Time stamped %s maps with %s available in mapset <%s>:\n")%\
-                                             (sp.get_type(),  time,  key))
-                else:
-                    sys.stderr.write(_("Space time %s datasets with %s available in mapset <%s>:\n")%\
-                                             (sp.get_new_map_instance(None).get_type(),  time,  key))
-
-                if separator is None or separator == "":
-                    separator = "\t"
-        
-                # Print the column names if requested
-                if colhead == True and first == True:
-                    output = ""
-                    count = 0
-                    for key in rows[0].keys():
-                        if count > 0:
-                            output += separator + str(key)
-                        else:
-                            output += str(key)
-                        count += 1
-                    print output
-                    first = False
-        
-                for row in rows:
-                    output = ""
-                    count = 0
-                    for col in row:
-                        if count > 0:
-                            output += separator + str(col)
-                        else:
-                            output += str(col)
-                        count += 1
-        
-                    print output
+        for key in mapsets:
+            if key in stds_list.keys():
+                rows = stds_list[key]
+
+                if rows:
+                    if issubclass(sp.__class__,  tgis.AbstractMapDataset):
+                        sys.stderr.write(_("Time stamped %s maps with %s available in mapset <%s>:\n")%\
+                                                 (sp.get_type(),  time,  key))
+                    else:
+                        sys.stderr.write(_("Space time %s datasets with %s available in mapset <%s>:\n")%\
+                                                 (sp.get_new_map_instance(None).get_type(),  time,  key))
+
+                    if separator is None or separator == "":
+                        separator = "\t"
+            
+                    # Print the column names if requested
+                    if colhead == True and first == True:
+                        output = ""
+                        count = 0
+                        for key in rows[0].keys():
+                            if count > 0:
+                                output += separator + str(key)
+                            else:
+                                output += str(key)
+                            count += 1
+                        print output
+                        first = False
+            
+                    for row in rows:
+                        output = ""
+                        count = 0
+                        for col in row:
+                            if count > 0:
+                                output += separator + str(col)
+                            else:
+                                output += str(col)
+                            count += 1
+            
+                        print output
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     options, flags = grass.parser()
     options, flags = grass.parser()