def sort_by_priority(a, b): priority_option = "priority" a_priority = 0 b_priority = 0 if config.has_option(a, priority_option): a_priority = config.getint(a, priority_option) if config.has_option(b, priority_option): b_priority = config.getint(b, priority_option) return cmp(b_priority, a_priority)
def load_all_plugins(cls): def section_priority(section_needing_key): priority_option = "priority" if config.has_option(section_needing_key, priority_option): return config.getint(section_needing_key, priority_option) return 0 sections = sorted(config.sections(), key=section_priority) for section in sections: if section.startswith("plugin:"): if config.getint(section, "enable"): logger.debug("Loading plugin '%s'" % section) cls.load_plugin(config.get(section, "module"))
def load_all_plugins(cls): def sort_by_priority(a, b): priority_option = "priority" a_priority = 0 b_priority = 0 if config.has_option(a, priority_option): a_priority = config.getint(a, priority_option) if config.has_option(b, priority_option): b_priority = config.getint(b, priority_option) return cmp(b_priority, a_priority) sections = sorted(config.sections(), cmp=sort_by_priority) for section in sections: if section.startswith("plugin:"): if config.getint(section, "enable"): logger.debug("Loading plugin '%s'" % section) cls.load_plugin(config.get(section, "module"))
def section_priority(section_needing_key): priority_option = "priority" if config.has_option(section_needing_key, priority_option): return config.getint(section_needing_key, priority_option) return 0