Ejemplo n.º 1
0
def get_handlers():
    try:
        from config import py as cfg
        plugin_utils.initialize_plugins(cfg.get("plugin_dirs", []),
                                        cfg.get("load_plugins", None))
    except ImportError:
        pass

    handlers_dict = dict([(v[0], (v[1], v[2])) for v in DEFAULT_HANDLERS])
    handlers_dict = run_callback("commandline", handlers_dict,
                                 mappingfunc=lambda x, y: y,
                                 defaultfunc=lambda x: x)

    # test the handlers, drop any that aren't the right return type,
    # and print a warning.
    handlers = []
    for k, v in handlers_dict.items():
        if not len(v) == 2 or not callable(v[0]) or not isinstance(v[1], str):
            print "Plugin returned '%s' for commandline." % ((k, v),)
            continue
        handlers.append((k, v[0], v[1]))

    return handlers
Ejemplo n.º 2
0
def get_handlers():
    try:
        from config import py as cfg
        plugin_utils.initialize_plugins(cfg.get("plugin_dirs", []),
                                        cfg.get("load_plugins", None))
    except ImportError:
        pass

    handlers_dict = dict([(v[0], (v[1], v[2])) for v in DEFAULT_HANDLERS])
    handlers_dict = run_callback("commandline",
                                 handlers_dict,
                                 mappingfunc=lambda x, y: y,
                                 defaultfunc=lambda x: x)

    # test the handlers, drop any that aren't the right return type,
    # and print a warning.
    handlers = []
    for k, v in handlers_dict.items():
        if not len(v) == 2 or not callable(v[0]) or not isinstance(v[1], str):
            print "Plugin returned '%s' for commandline." % ((k, v), )
            continue
        handlers.append((k, v[0], v[1]))

    return handlers
Ejemplo n.º 3
0
def build_folksonomy(command, argv):
    """Command for building the folksonomy tables."""
    from config import py as config

    cachefile = config.get("folksonomy_cache")
    if not cachefile:
        raise ValueError("config.py has no folksonomy cache file property.")

    if "tag_url" not in config:
        config["tag_url"] = "%s/%s/" % (config["base_url"], "tags")

    folksonomy = create_folksonomy(config)
    with open(cachefile, "w") as cache:
        cPickle.dump(folksonomy, cache)

    return 0
Ejemplo n.º 4
0
def build_folksonomy(command, argv):
    """Command for building the folksonomy tables."""
    from config import py as config

    cachefile = config.get("folksonomy_cache")
    if not cachefile:
        raise ValueError("config.py has no folksonomy cache file property.")

    if 'tag_url' not in config:
        config['tag_url'] = "%s/%s/" % (config['base_url'], 'tags')

    folksonomy = create_folksonomy(config)
    with open(cachefile, "w") as cache:
        cPickle.dump(folksonomy, cache)

    return 0