[kupfer: 5/31] data: Add accessor o access "pre-root": all firstlevel sources



commit ab284a3589ee7ab0f1411b27dbdf4ae117343f01
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Dec 30 15:23:32 2009 +0100

    data: Add accessor o access "pre-root": all firstlevel sources

 kupfer/data.py |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index d20db77..ab82b68 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -333,19 +333,24 @@ class SourceController (pretty.OutputMixin):
 		if len(self.sources) == 1:
 			root_catalog, = self.sources
 		elif len(self.sources) > 1:
-			sourceindex = set(self.sources)
-			kupfer_sources = objects.SourcesSource(self.sources)
-			sourceindex.add(kupfer_sources)
-			# Make sure firstlevel is ordered
-			# So that it keeps the ordering.. SourcesSource first
-			firstlevel = []
-			firstlevel.append(objects.SourcesSource(sourceindex))
-			firstlevel.extend(set(self.toplevel_sources))
+			firstlevel = self._pre_root
 			root_catalog = objects.MultiSource(firstlevel)
 		else:
 			root_catalog = None
 		return root_catalog
 
+	@property
+	def _pre_root(self):
+		sourceindex = set(self.sources)
+		kupfer_sources = objects.SourcesSource(self.sources)
+		sourceindex.add(kupfer_sources)
+		# Make sure firstlevel is ordered
+		# So that it keeps the ordering.. SourcesSource first
+		firstlevel = []
+		firstlevel.append(objects.SourcesSource(sourceindex))
+		firstlevel.extend(set(self.toplevel_sources))
+		return firstlevel
+
 	@classmethod
 	def good_source_for_types(cls, s, types):
 		"""return whether @s provides good leaves for @types



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