diff --git a/src/PluginUtils/_PluginDialogs.py b/src/PluginUtils/_PluginDialogs.py
index 65d6c5ecc..f1200e9fe 100644
--- a/src/PluginUtils/_PluginDialogs.py
+++ b/src/PluginUtils/_PluginDialogs.py
@@ -33,6 +33,7 @@ import gtk
#
#-------------------------------------------------------------------------
from gettext import gettext as _
+from collections import defaultdict
#-------------------------------------------------------------------------
#
@@ -186,16 +187,13 @@ class PluginDialog(ManagedWindow.ManagedWindow):
self.store.clear()
# build the tree items and group together based on the category name
- item_hash = {}
+ item_hash = defaultdict()
for plugin in reg_list:
if not plugin.supported:
category = _UNSUPPORTED
else:
category = categories[plugin.category]
- if category in item_hash:
- item_hash[category].append(plugin)
- else:
- item_hash[category] = [plugin]
+ item_hash[category].append(plugin)
# add a submenu for each category, and populate it with the
# GtkTreeItems that are associated with it.
diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py
index 9907d69e9..79a1008ae 100644
--- a/src/gui/viewmanager.py
+++ b/src/gui/viewmanager.py
@@ -35,6 +35,7 @@ import os
from gettext import gettext as _
from cStringIO import StringIO
+from collections import defaultdict
#-------------------------------------------------------------------------
#
@@ -1489,22 +1490,19 @@ class ViewManager(CLIManager):
menu = gtk.Menu()
menu.show()
-
- hash_data = {}
+
+ hash_data = defaultdict(list)
for pdata in item_list:
if not pdata.supported:
category = _UNSUPPORTED
else:
category = categories[pdata.category]
- if category in hash_data:
- hash_data[category].append(pdata)
- else:
- hash_data[category] = [pdata]
-
+ hash_data[category].append(pdata)
+
# Sort categories, skipping the unsupported
- catlist = [item for item in hash_data
- if item != _UNSUPPORTED]
- catlist.sort()
+ catlist = sorted(item for item in hash_data
+ if item != _UNSUPPORTED)
+
for key in catlist:
new_key = key.replace(' ', '-')
ofile.write('