Ejemplo n.º 1
0
 def _firstlevel(self):
     if self._pre_root:
         return self._pre_root
     sourceindex = set(self.sources)
     kupfer_sources = sources.SourcesSource(self.sources)
     sourceindex.add(kupfer_sources)
     # Make sure firstlevel is ordered
     # So that it keeps the ordering.. SourcesSource first
     firstlevel = []
     firstlevel.append(sources.SourcesSource(sourceindex))
     firstlevel.extend(set(self.toplevel_sources))
     self._pre_root = firstlevel
     return firstlevel
Ejemplo n.º 2
0
	def decorate_object(self, obj, action=None):
		if hasattr(obj, "has_content"):
			types = tuple(action.object_types()) if action else ()
			contents = list(self.get_contents_for_leaf(obj, types))
			content = contents[0] if contents else None
			if len(contents) > 1:
				content = sources.SourcesSource(contents, name=unicode(obj),
						use_reprs=False)
			obj.add_content(content)
Ejemplo n.º 3
0
	def root_for_types(self, types):
		"""
		Get root for a flat catalog of all catalogs
		providing at least Leaves of @types

		Take all sources which:
			Provide a type T so that it is a subclass
			to one in the set of types we want
		"""
		types = tuple(types)
		firstlevel = set()
		# include the Catalog index since we want to include
		# the top of the catalogs (like $HOME)
		catalog_index = (sources.SourcesSource(self.sources), )
		for s in itertools.chain(self.sources, catalog_index):
			if self.good_source_for_types(s, types):
				firstlevel.add(s)
		return sources.MultiSource(firstlevel)