}
static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
+ const char* kwlist[] = { "ctx", "path", "arch", "config", NULL };
struct pakfire_config* c = NULL;
- const char* kwlist[] = { "ctx", "path", "arch", "conf", NULL };
- CtxObject* ctx = NULL;
+ const char* config = NULL;
const char* path = NULL;
const char* arch = NULL;
- PyObject* conf = Py_None;
- int r = 1;
+ CtxObject* ctx = NULL;
+ int r;
- FILE* f = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|zzO", (char**)kwlist,
- &CtxType, &ctx, &path, &arch, &conf))
- goto ERROR;
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|zzz", (char**)kwlist,
+ &CtxType, &ctx, &path, &arch, &config))
+ return -1;
// Create a new configuration object
r = pakfire_config_create(&c);
goto ERROR;
}
- // Map the configuration
- if (conf != Py_None) {
- f = PyObject_AsFileHandle(conf, "r");
- if (!f)
- goto ERROR;
-
- // Read the configuration
- r = pakfire_config_read(c, f);
+ // Parse the configuration
+ if (config) {
+ r = pakfire_config_parse(c, config, -1);
if (r < 0) {
+ errno = -r;
+
PyErr_SetFromErrno(PyExc_OSError);
goto ERROR;
}
}
- int flags = 0;
-
Py_BEGIN_ALLOW_THREADS
// Store a reference to the context
self->ctx = pakfire_ctx_ref(ctx->ctx);
// Create a new Pakfire instance
- r = pakfire_create(&self->pakfire, self->ctx, c, path, arch, flags);
+ r = pakfire_create(&self->pakfire, self->ctx, c, path, arch, 0);
Py_END_ALLOW_THREADS
// Invalid architecture or path
case EINVAL:
PyErr_SetString(PyExc_ValueError, "Invalid architecture or path");
- break;
+ goto ERROR;
// Anything else
default:
PyErr_SetFromErrno(PyExc_OSError);
+ goto ERROR;
}
-
- r = -1;
- goto ERROR;
}
ERROR:
if (c)
pakfire_config_unref(c);
- if (f)
- fclose(f);
- return -r;
+ return r;
}
static void Pakfire_dealloc(PakfireObject* self) {