gather collections having the same path

This commit is contained in:
Bezleputh 2014-05-07 18:24:48 +02:00
commit 7b799a6fbb

View file

@ -1029,6 +1029,7 @@ class ReplApplication(Cmd, ConsoleApplication):
if sort:
objects.sort(cmp=comp_object)
collections = self._merge_collections_with_same_path(collections)
collections.sort(cmp=comp_object)
for collection in collections:
self._format_collection(collection, only)
@ -1042,6 +1043,22 @@ class ReplApplication(Cmd, ConsoleApplication):
# Save collections only if we listed the current path.
self.collections = collections
def _find_collection(self, collection, collections):
for col in collections:
if col.split_path == collection.split_path:
return col
return None
def _merge_collections_with_same_path(self, collections):
to_return = []
for collection in collections:
col = self._find_collection(collection, to_return)
if col:
col.backend += " %s" % collection.backend
else:
to_return.append(collection)
return to_return
def _format_collection(self, collection, only):
if only is False or collection.basename in only: