Exemplo n.º 1
0
def create_process_list_from_user_data(data):
    """
    Creates a process list from user supplied data.
    """
    process_list = Content()

    # For each plugin
    for i, pl in enumerate(data['plugins']):
        pos = str(i + 1)

        # Add plugin
        process_list.add(pl['name'], pos)

        # Set plugin enable state
        process_list.on_and_off(
            pos,
            const.PLUGIN_ENABLED if pl['active'] else const.PLUGIN_DISABLED)

        # Set parameter values
        for param in pl['parameters']:
            if param['name'] == 'preview':
                # Don't cast a preview value, since it always comes into
                # flask as a string and should always be cast to a string, but
                # sometimes it can have a value of '[]' which gets cast to the
                # empty list by Content.value() and plugin.utils._dumps()
                cast_param_val = param['value']
            else:
                cast_param_val = process_list.value(param['value'])

            process_list.modify(pos, param['name'], cast_param_val, ref=True)

    return process_list
Exemplo n.º 2
0
def create_process_list_from_user_data(data):
    """
    Creates a process list from user supplied data.
    """
    process_list = Content()

    # For each plugin
    for i, pl in enumerate(data['plugins']):
        pos = str(i + 1)

        # Add plugin
        process_list.add(pl['name'], pos)

        # Set plugin enable state
        process_list.on_and_off(
            pos,
            const.PLUGIN_ENABLED if pl['active'] else const.PLUGIN_DISABLED)

        # Set parameter values
        for param in pl['parameters']:
            cast_param_val = process_list.value(param['value'])
            process_list.modify(pos, param['name'], cast_param_val, ref=True)

    return process_list