示例#1
0
static PyObject *
python_api_completer_remove(PyObject *self, PyObject *args)
{
    PyObject *key = NULL;
    PyObject *items = NULL;

    if (!PyArg_ParseTuple(args, "OO", &key, &items)) {
        Py_RETURN_NONE;
    }

    char *key_str = python_str_or_unicode_to_string(key);

    char *plugin_name = _python_plugin_name();
    log_debug("Autocomplete remove %s for %s", key_str, plugin_name);

    Py_ssize_t len = PyList_Size(items);
    char *c_items[len];

    Py_ssize_t i = 0;
    for (i = 0; i < len; i++) {
        PyObject *item = PyList_GetItem(items, i);
        char *c_item = python_str_or_unicode_to_string(item);
        c_items[i] = c_item;
    }
    c_items[len] = NULL;

    allow_python_threads();
    api_completer_remove(plugin_name, key_str, c_items);
    free(key_str);
    disable_python_threads();

    free(plugin_name);

    Py_RETURN_NONE;
}
示例#2
0
文件: c_api.c 项目: anossov/profanity
static void
c_api_completer_remove(const char *filename, const char *key, char **items)
{
    char *plugin_name = _c_plugin_name(filename);
    log_debug("Autocomplete remove %s for %s", key, plugin_name);

    api_completer_remove(plugin_name, key, items);

    free(plugin_name);
}