def collectCategoriesAndSpokes(paths, klass, displaymode): """Collects categories and spokes to be displayed on this Hub :param paths: dictionary mapping categories, spokes, and hubs to their their respective search path(s) :return: dictionary mapping category class to list of spoke classes :rtype: dictionary[category class] -> [ list of spoke classes ] """ ret = {} # Collect all the categories this hub displays, then collect all the # spokes belonging to all those categories. if displaymode == DISPLAY_MODE_TEXT: categories = sorted(filter(lambda c: c.displayOnHubTUI == klass.__name__, collect_categories(paths["categories"], displaymode)), key=lambda c: c.sortOrder) else: categories = sorted(filter(lambda c: c.displayOnHubGUI == klass.__name__, collect_categories(paths["categories"], displaymode)), key=lambda c: c.sortOrder) for c in categories: ret[c] = collect_spokes(paths["spokes"], c.__name__) # As we now have a list of all categories this hub holds we can now register it's controller. # We need the list of categories so that spokes can find out which controller they should use # based on their category. category_names = set() for c in categories: category_names.add(c.__name__) # We have gathered all known category names and more are not expected to be added, # so we can now add an initialization controller, which needs the final list # of categories for the given hub. lifecycle.add_controller(klass.__name__, category_names) return ret
def collectCategoriesAndSpokes(paths, klass): """Collects categories and spokes to be displayed on this Hub :param paths: dictionary mapping categories, spokes, and hubs to their their respective search path(s) :return: dictionary mapping category class to list of spoke classes :rtype: dictionary[category class] -> [ list of spoke classes ] """ ret = {} # Collect all the categories this hub displays, then collect all the # spokes belonging to all those categories. categories = collect_categories(paths["categories"]) for c in categories: ret[c] = collect_spokes(paths["spokes"], c.__name__) # As we now have a list of all categories this hub holds we can now register it's controller. # We need the list of categories so that spokes can find out which controller they should use # based on their category. category_names = set() for c in categories: category_names.add(c.__name__) # We have gathered all known category names and more are not expected to be added, # so we can now add an initialization controller, which needs the final list # of categories for the given hub. lifecycle.add_controller(klass.__name__, category_names) return ret