Main Page Modules Data Structures File List Data Fields Globals Related Pages

# python/rpmte-py.c

Go to the documentation of this file.

    00001
    00005 #include "system.h"
    00006
    00007 #include "Python.h"
    00008 #ifdef __LCLINT__
    00009 #undef  PyObject_HEAD
    00010 #define PyObject_HEAD   int _PyObjectHead;
    00011 #endif
    00012
    00013 #include <rpmlib.h>
    00014
    00015 #include "header-py.h"  /* XXX tagNumFromPyObject */
    00016 #include "rpmds-py.h"
    00017 #include "rpmfi-py.h"
    00018 #include "rpmte-py.h"
    00019
    00020 #include "debug.h"
    00021
    00051 static PyObject *
    00052 rpmte_Debug(/*@unused@*/ rpmteObject * s, /*@unused@*/ PyObject * args)
    00053         /*@globals _Py_NoneStruct @*/
    00054         /*@modifies _Py_NoneStruct @*/
    00055 {
    00056     if (!PyArg_ParseTuple(args, "i", &_rpmte_debug)) return NULL;
    00057     Py_INCREF(Py_None);
    00058     return Py_None;
    00059 }
    00060
    00061 static PyObject *
    00062 rpmte_N(rpmteObject * s, PyObject * args)
    00063         /*@*/
    00064 {
    00065     if (!PyArg_ParseTuple(args, ":N")) return NULL;
    00066     return Py_BuildValue("s", rpmteN(s->te));
    00067 }
    00068
    00069 static PyObject *
    00070 rpmte_E(rpmteObject * s, PyObject * args)
    00071         /*@*/
    00072 {
    00073     if (!PyArg_ParseTuple(args, ":E")) return NULL;
    00074     return Py_BuildValue("s", rpmteE(s->te));
    00075 }
    00076
    00077 static PyObject *
    00078 rpmte_V(rpmteObject * s, PyObject * args)
    00079         /*@*/
    00080 {
    00081     if (!PyArg_ParseTuple(args, ":V")) return NULL;
    00082     return Py_BuildValue("s", rpmteV(s->te));
    00083 }
    00084
    00085 static PyObject *
    00086 rpmte_R(rpmteObject * s, PyObject * args)
    00087         /*@*/
    00088 {
    00089     if (!PyArg_ParseTuple(args, ":R")) return NULL;
    00090     return Py_BuildValue("s", rpmteR(s->te));
    00091 }
    00092
    00093 static PyObject *
    00094 rpmte_A(rpmteObject * s, PyObject * args)
    00095         /*@*/
    00096 {
    00097     if (!PyArg_ParseTuple(args, ":A")) return NULL;
    00098     return Py_BuildValue("s", rpmteA(s->te));
    00099 }
    00100
    00101 static PyObject *
    00102 rpmte_O(rpmteObject * s, PyObject * args)
    00103         /*@*/
    00104 {
    00105     if (!PyArg_ParseTuple(args, ":O")) return NULL;
    00106     return Py_BuildValue("s", rpmteO(s->te));
    00107 }
    00108
    00109 static PyObject *
    00110 rpmte_NEVR(rpmteObject * s, PyObject * args)
    00111         /*@*/
    00112 {
    00113     if (!PyArg_ParseTuple(args, ":NEVR")) return NULL;
    00114     return Py_BuildValue("s", rpmteNEVR(s->te));
    00115 }
    00116
    00117 static PyObject *
    00118 rpmte_MultiLib(rpmteObject * s, PyObject * args)
    00119         /*@*/
    00120 {
    00121     if (!PyArg_ParseTuple(args, ":MultiLib")) return NULL;
    00122     return Py_BuildValue("i", rpmteMultiLib(s->te));
    00123 }
    00124
    00125 static PyObject *
    00126 rpmte_Depth(rpmteObject * s, PyObject * args)
    00127         /*@*/
    00128 {
    00129     if (!PyArg_ParseTuple(args, ":Depth")) return NULL;
    00130     return Py_BuildValue("i", rpmteDepth(s->te));
    00131 }
    00132
    00133 static PyObject *
    00134 rpmte_Npreds(rpmteObject * s, PyObject * args)
    00135         /*@*/
    00136 {
    00137     if (!PyArg_ParseTuple(args, ":Npreds")) return NULL;
    00138     return Py_BuildValue("i", rpmteNpreds(s->te));
    00139 }
    00140
    00141 static PyObject *
    00142 rpmte_Degree(rpmteObject * s, PyObject * args)
    00143         /*@*/
    00144 {
    00145     if (!PyArg_ParseTuple(args, ":Degree")) return NULL;
    00146     return Py_BuildValue("i", rpmteDegree(s->te));
    00147 }
    00148
    00149 static PyObject *
    00150 rpmte_AddedKey(rpmteObject * s, PyObject * args)
    00151         /*@*/
    00152 {
    00153     if (!PyArg_ParseTuple(args, ":Degree")) return NULL;
    00154     return Py_BuildValue("i", rpmteDegree(s->te));
    00155 }
    00156
    00157 static PyObject *
    00158 rpmte_DS(rpmteObject * s, PyObject * args)
    00159         /*@*/
    00160 {
    00161     PyObject * TagN = NULL;
    00162     rpmds ds;
    00163     rpmTag tag;
    00164
    00165     if (!PyArg_ParseTuple(args, "O:DS", &TagN)) return NULL;
    00166
    00167     tag = tagNumFromPyObject(TagN);
    00168     if (tag == -1) {
    00169         PyErr_SetString(PyExc_TypeError, "unknown tag type");
    00170         return NULL;
    00171     }
    00172
    00173     ds = rpmteDS(s->te, tag);
    00174     if (ds == NULL) {
    00175 #ifdef  DYING
    00176         PyErr_SetString(PyExc_TypeError, "invalid ds tag");
    00177         return NULL;
    00178 #else
    00179         Py_INCREF(Py_None);
    00180         return Py_None;
    00181 #endif
    00182     }
    00183     return (PyObject *) rpmds_Wrap(rpmdsLink(ds, "rpmte_DS"));
    00184 }
    00185
    00186 static PyObject *
    00187 rpmte_FI(rpmteObject * s, PyObject * args)
    00188         /*@*/
    00189 {
    00190     PyObject * TagN = NULL;
    00191     rpmfi fi;
    00192     rpmTag tag;
    00193
    00194     if (!PyArg_ParseTuple(args, "O:FI", &TagN)) return NULL;
    00195
    00196     tag = tagNumFromPyObject(TagN);
    00197     if (tag == -1) {
    00198         PyErr_SetString(PyExc_TypeError, "unknown tag type");
    00199         return NULL;
    00200     }
    00201
    00202     fi = rpmteFI(s->te, tag);
    00203     if (fi == NULL) {
    00204 #ifdef  DYING
    00205         PyErr_SetString(PyExc_TypeError, "invalid fi tag");
    00206         return NULL;
    00207 #else
    00208         Py_INCREF(Py_None);
    00209         return Py_None;
    00210 #endif
    00211     }
    00212     return (PyObject *) rpmfi_Wrap(rpmfiLink(fi, "rpmte_FI"));
    00213 }
    00214
    00217 /*@-fullinitblock@*/
    00218 /*@unchecked@*/ /*@observer@*/
    00219 static struct PyMethodDef rpmte_methods[] = {
    00220     {"Debug",   (PyCFunction)rpmte_Debug,       METH_VARARGS,
    00221         NULL},
    00222     {"N",       (PyCFunction)rpmte_N,           METH_VARARGS,
    00223 "te.N() -> N\n\
    00224 - Return element name.\n" },
    00225     {"E",       (PyCFunction)rpmte_E,           METH_VARARGS,
    00226 "te.E() -> E\n\
    00227 - Return element epoch.\n" },
    00228     {"V",       (PyCFunction)rpmte_V,           METH_VARARGS,
    00229 "te.V() -> V\n\
    00230 - Return element version.\n" },
    00231     {"R",       (PyCFunction)rpmte_R,           METH_VARARGS,
    00232 "te.R() -> R\n\
    00233 - Return element release.\n" },
    00234     {"A",       (PyCFunction)rpmte_A,           METH_VARARGS,
    00235 "te.A() -> A\n\
    00236 - Return element arch.\n" },
    00237     {"O",       (PyCFunction)rpmte_O,           METH_VARARGS,
    00238 "te.O() -> O\n\
    00239 - Return element os.\n" },
    00240     {"NEVR",    (PyCFunction)rpmte_NEVR,        METH_VARARGS,
    00241 "te.NEVR() -> NEVR\n\
    00242 - Return element name-version-release.\n" },
    00243     {"MultiLib",(PyCFunction)rpmte_MultiLib,    METH_VARARGS,
    00244         NULL},
    00245     {"Depth",   (PyCFunction)rpmte_Depth,       METH_VARARGS,
    00246         NULL},
    00247     {"Npreds",  (PyCFunction)rpmte_Npreds,      METH_VARARGS,
    00248         NULL},
    00249     {"Degree",  (PyCFunction)rpmte_Degree,      METH_VARARGS,
    00250         NULL},
    00251     {"AddedKey",(PyCFunction)rpmte_AddedKey,    METH_VARARGS,
    00252         NULL},
    00253     {"DS",      (PyCFunction)rpmte_DS,          METH_VARARGS,
    00254 "te.DS(TagN) -> DS\n\
    00255 - Return the TagN dependency set (or None). TagN is one of\n\
    00256         'Providename', 'Requirename', 'Obsoletename', 'Conflictname'\n" },
    00257     {"FI",      (PyCFunction)rpmte_FI,          METH_VARARGS,
    00258 "te.FI(TagN) -> FI\n\
    00259 - Return the TagN dependency set (or None). TagN must be 'Basenames'.\n" },
    00260     {NULL,              NULL}           /* sentinel */
    00261 };
    00262 /*@=fullinitblock@*/
    00263
    00264 /* ---------- */
    00265
    00268 static PyObject * rpmte_getattr(rpmteObject * o, char * name)
    00269         /*@*/
    00270 {
    00271     return Py_FindMethod(rpmte_methods, (PyObject *) o, name);
    00272 }
    00273
    00276 /*@unchecked@*/ /*@observer@*/
    00277 static char rpmte_doc[] =
    00278 "";
    00279
    00282 /*@-fullinitblock@*/
    00283 PyTypeObject rpmte_Type = {
    00284         PyObject_HEAD_INIT(NULL)
    00285         0,                              /* ob_size */
    00286         "rpm.te",                       /* tp_name */
    00287         sizeof(rpmteObject),            /* tp_size */
    00288         0,                              /* tp_itemsize */
    00289         (destructor)0,                  /* tp_dealloc */
    00290         0,                              /* tp_print */
    00291         (getattrfunc) rpmte_getattr,    /* tp_getattr */
    00292         (setattrfunc)0,                 /* tp_setattr */
    00293         0,                              /* tp_compare */
    00294         0,                              /* tp_repr */
    00295         0,                              /* tp_as_number */
    00296         0,                              /* tp_as_sequence */
    00297         0,                              /* tp_as_mapping */
    00298         0,                              /* tp_hash */
    00299         0,                              /* tp_call */
    00300         0,                              /* tp_str */
    00301         0,                              /* tp_getattro */
    00302         0,                              /* tp_setattro */
    00303         0,                              /* tp_as_buffer */
    00304         Py_TPFLAGS_DEFAULT,             /* tp_flags */
    00305         rpmte_doc,                      /* tp_doc */
    00306 #if Py_TPFLAGS_HAVE_ITER
    00307         0,                              /* tp_traverse */
    00308         0,                              /* tp_clear */
    00309         0,                              /* tp_richcompare */
    00310         0,                              /* tp_weaklistoffset */
    00311         0,                              /* tp_iter */
    00312         0,                              /* tp_iternext */
    00313         rpmte_methods,                  /* tp_methods */
    00314         0,                              /* tp_members */
    00315         0,                              /* tp_getset */
    00316         0,                              /* tp_base */
    00317         0,                              /* tp_dict */
    00318         0,                              /* tp_descr_get */
    00319         0,                              /* tp_descr_set */
    00320         0,                              /* tp_dictoffset */
    00321         0,                              /* tp_init */
    00322         0,                              /* tp_alloc */
    00323         0,                              /* tp_new */
    00324         0,                              /* tp_free */
    00325         0,                              /* tp_is_gc */
    00326 #endif
    00327 };
    00328 /*@=fullinitblock@*/
    00329
    00330 rpmteObject * rpmte_Wrap(rpmte te)
    00331 {
    00332     rpmteObject *s = PyObject_NEW(rpmteObject, &rpmte_Type);
    00333     if (s == NULL)
    00334         return NULL;
    00335     s->te = te;
    00336     return s;
    00337 }