[kupfer] data: Cleanup in register_action_decorators



commit f1fe5426befdd8b8403d33d8504184c41850bb31
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Oct 29 22:26:07 2009 +0100

    data: Cleanup in register_action_decorators

 kupfer/data.py |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index d27dfcd..3e812f0 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -770,15 +770,12 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		sc = GetSourceController()
 		sc.add_text_sources(srcs)
 	
-	def register_action_decorators(self, acts):
-		# Keep a dictionary with Leaf type as key
+	def register_action_decorators(self, actions):
+		# Keep a mapping: Decorated Leaf Type -> List of actions
 		decorate_types = {}
-		for act in acts:
-			applies = act.item_types()
-			for appl_type in applies:
-				decorate_with = decorate_types.get(appl_type, [])
-				decorate_with.append(act)
-				decorate_types[appl_type] = decorate_with
+		for action in actions:
+			for appl_type in action.item_types():
+				decorate_types.setdefault(appl_type, []).append(action)
 		sc = GetSourceController()
 		sc.set_action_decorators(decorate_types)
 		self.output_debug("Action decorators:")



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]