def get_enabled_plugins(): """ Open plugin config files from plugin_config_dir and determine if they are enabled. If so, append them to 'enabled_plugins' in the root config. Uses the namespaces['root'].config dictionary. """ config = get_config() if config.has_key('enabled_plugins'): enabled_plugins = config['enabled_plugins'] else: enabled_plugins = [] # determine enabled plugins # first from config files for _file in config['config_files']: try: cnf = ConfigObj(_file) except IOError, error: log.warning("Unable to open config '%s': %s" % \ (_file, error.args[1])) continue for sect in cnf.sections: if sect != 'root' and cnf[sect].has_key('enable_plugin') \ and t_f_pass(cnf[sect]['enable_plugin']) == True \ and not sect in enabled_plugins: if not cnf[sect].has_key('provider'): provider = config['app_module'] else: provider = cnf[sect]['provider'] setup_logging_for_plugin_provider(provider) plugin = "%s.plugin.%s" % (provider, sect) if plugin not in enabled_plugins: enabled_plugins.append(plugin)
provider = cnf[sect]['provider'] setup_logging_for_plugin_provider(provider) plugin = "%s.plugin.%s" % (provider, sect) if plugin not in enabled_plugins: enabled_plugins.append(plugin) # Then for plugin config files for _file in os.listdir(config['plugin_config_dir']): path = os.path.join(config['plugin_config_dir'], _file) if not path.endswith('.conf'): continue cnf = ConfigObj(path) for sect in cnf.sections: if sect != 'root' and cnf[sect].has_key('enable_plugin') \ and t_f_pass(cnf[sect]['enable_plugin']) == True \ and not sect in enabled_plugins: if not cnf[sect].has_key('provider'): provider = config['app_module'] else: provider = cnf[sect]['provider'] setup_logging_for_plugin_provider(provider) plugin = "%s.plugin.%s" % (provider, sect) if plugin not in enabled_plugins: enabled_plugins.append(plugin) return enabled_plugins def load_plugin(plugin): """ Load a cement plugin.
def check_pass(val): assert t_f_pass(val) == val
def check_false(val): assert t_f_pass(val) == False
def check_true(val): assert t_f_pass(val) == True