Py_RETURN_NONE;
}
-static PyObject* Pakfire_keys_to_list(struct pakfire_key** keys) {
- PyObject* list = PyList_New(0);
-
- // Empty input?
- if (!keys)
- return list;
-
- // Push all keys onto the list
- for (struct pakfire_key** key = keys; *key; key++) {
- PyObject* object = new_key(&KeyType, *key);
- if (!object)
- goto ERROR;
-
- PyList_Append(list, object);
- Py_DECREF(object);
- }
-
- return list;
-
-ERROR:
- Py_DECREF(list);
- return NULL;
-}
-
-static PyObject* Pakfire_get_keys(PakfireObject* self) {
- struct pakfire_key** keys = NULL;
-
- int r = pakfire_list_keys(self->pakfire, &keys);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- // Convert keys to list
- PyObject* list = Pakfire_keys_to_list(keys);
-
- // Free keys
- if (keys) {
- for (struct pakfire_key** key = keys; *key; key++)
- pakfire_key_unref(*key);
- free(keys);
- }
-
- return list;
-}
-
static PyObject* Pakfire_generate_key(PakfireObject* self, PyObject* args, PyObject* kwds) {
char* kwlist[] = { "algorithm", NULL };
struct pakfire_key* key = NULL;
NULL,
NULL
},
- {
- "keys",
- (getter)Pakfire_get_keys,
- NULL,
- NULL,
- NULL
- },
{
"path",
(getter)Pakfire_get_path,