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