00001
00005 #include "system.h"
00006
00007 #include <rpmcb.h>
00008 #include <rpmlib.h>
00009
00010 #include "rpmal-py.h"
00011 #include "rpmds-py.h"
00012 #include "rpmfi-py.h"
00013
00014 #include "debug.h"
00015
00016
00017 static PyObject *
00018 rpmal_Debug( rpmalObject * s, PyObject * args, PyObject * kwds)
00019
00020
00021 {
00022 char * kwlist[] = {"debugLevel", NULL};
00023
00024 if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmal_debug))
00025 return NULL;
00026
00027 Py_INCREF(Py_None);
00028 return Py_None;
00029 }
00030
00031
00032 static PyObject *
00033 rpmal_Add(rpmalObject * s, PyObject * args, PyObject * kwds)
00034
00035 {
00036 rpmdsObject * dso;
00037 rpmfiObject * fio;
00038 PyObject * key;
00039 alKey pkgKey;
00040 char * kwlist[] = {"packageKey", "key", "dso", "fileInfo", NULL};
00041
00042 if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:Add", kwlist,
00043 &pkgKey, &key, &rpmds_Type, &dso, &rpmfi_Type, &fio))
00044 return NULL;
00045
00046
00047
00048 pkgKey = rpmalAdd(&s->al, pkgKey, key, dso->ds, fio->fi, 0);
00049
00050 return Py_BuildValue("i", pkgKey);
00051 }
00052
00053
00054 static PyObject *
00055 rpmal_Del(rpmalObject * s, PyObject * args, PyObject * kwds)
00056
00057
00058 {
00059 alKey pkgKey;
00060 char * kwlist[] = {"key", NULL};
00061
00062 if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Del", kwlist, &pkgKey))
00063 return NULL;
00064
00065 rpmalDel(s->al, pkgKey);
00066
00067 Py_INCREF(Py_None);
00068 return Py_None;
00069 }
00070
00071
00072 static PyObject *
00073 rpmal_AddProvides(rpmalObject * s, PyObject * args, PyObject * kwds)
00074
00075
00076 {
00077 rpmdsObject * dso;
00078 alKey pkgKey;
00079 char * kwlist[] = {"index", "packageIndex", "dso", NULL};
00080
00081
00082
00083 if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:AddProvides", kwlist,
00084 &pkgKey, &rpmds_Type, &dso))
00085 return NULL;
00086
00087
00088 rpmalAddProvides(s->al, pkgKey, dso->ds, 0);
00089
00090 Py_INCREF(Py_None);
00091 return Py_None;
00092 }
00093
00094
00095 static PyObject *
00096 rpmal_MakeIndex(rpmalObject * s)
00097
00098
00099 {
00100 rpmalMakeIndex(s->al);
00101
00102 Py_INCREF(Py_None);
00103 return Py_None;
00104 }
00105
00106
00107
00108 static struct PyMethodDef rpmal_methods[] = {
00109 {"Debug", (PyCFunction)rpmal_Debug, METH_VARARGS|METH_KEYWORDS,
00110 NULL},
00111 {"add", (PyCFunction)rpmal_Add, METH_VARARGS|METH_KEYWORDS,
00112 NULL},
00113 {"delete", (PyCFunction)rpmal_Del, METH_VARARGS|METH_KEYWORDS,
00114 NULL},
00115 {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS|METH_KEYWORDS,
00116 NULL},
00117 {"makeIndex",(PyCFunction)rpmal_MakeIndex, METH_NOARGS,
00118 NULL},
00119 {NULL, NULL }
00120 };
00121
00122
00123
00124
00125 static void
00126 rpmal_dealloc(rpmalObject * s)
00127
00128 {
00129 if (s) {
00130 s->al = rpmalFree(s->al);
00131 PyObject_Del(s);
00132 }
00133 }
00134
00135 static PyObject * rpmal_getattro(PyObject * o, PyObject * n)
00136
00137 {
00138 return PyObject_GenericGetAttr(o, n);
00139 }
00140
00141 static int rpmal_setattro(PyObject * o, PyObject * n, PyObject * v)
00142
00143 {
00144 return PyObject_GenericSetAttr(o, n, v);
00145 }
00146
00149
00150 static char rpmal_doc[] =
00151 "";
00152
00153
00154
00155 PyTypeObject rpmal_Type = {
00156 PyObject_HEAD_INIT(&PyType_Type)
00157 0,
00158 "rpm.al",
00159 sizeof(rpmalObject),
00160 0,
00161
00162 (destructor) rpmal_dealloc,
00163 (printfunc)0,
00164 (getattrfunc)0,
00165 (setattrfunc)0,
00166 (cmpfunc)0,
00167 (reprfunc)0,
00168 0,
00169 0,
00170 0,
00171 (hashfunc)0,
00172 (ternaryfunc)0,
00173 (reprfunc)0,
00174 (getattrofunc) rpmal_getattro,
00175 (setattrofunc) rpmal_setattro,
00176 0,
00177 Py_TPFLAGS_DEFAULT,
00178 rpmal_doc,
00179 #if Py_TPFLAGS_HAVE_ITER
00180 0,
00181 0,
00182 0,
00183 0,
00184 (getiterfunc)0,
00185 (iternextfunc)0,
00186 rpmal_methods,
00187 0,
00188 0,
00189 0,
00190 0,
00191 0,
00192 0,
00193 0,
00194 0,
00195 0,
00196 0,
00197 0,
00198 0,
00199 #endif
00200 };
00201
00202
00203
00204
00205 rpmalObject *
00206 rpmal_Wrap(rpmal al)
00207 {
00208 rpmalObject *s = PyObject_New(rpmalObject, &rpmal_Type);
00209 if (s == NULL)
00210 return NULL;
00211 s->al = al;
00212 return s;
00213 }