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 <rpmlib.h>
00008 
00009 #include "header-py.h"  /* XXX tagNumFromPyObject */
00010 #include "rpmds-py.h"
00011 #include "rpmfi-py.h"
00012 #include "rpmte-py.h"
00013 
00014 #include "debug.h"
00015 
00016 /*@access rpmte @*/
00017 /*@access fnpyKey @*/
00018 
00062 
00063 /*@null@*/
00064 static PyObject *
00065 rpmte_Debug(/*@unused@*/ rpmteObject * s, PyObject * args, PyObject * kwds)
00066         /*@globals _Py_NoneStruct @*/
00067         /*@modifies _Py_NoneStruct @*/
00068 {
00069     char * kwlist[] = {"debugLevel", NULL};
00070 
00071     if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmte_debug))
00072         return NULL;
00073 
00074     Py_INCREF(Py_None);
00075     return Py_None;
00076 }
00077 
00078 /*@null@*/
00079 static PyObject *
00080 rpmte_TEType(rpmteObject * s)
00081         /*@*/
00082 {
00083     return Py_BuildValue("i", rpmteType(s->te));
00084 }
00085 
00086 /*@null@*/
00087 static PyObject *
00088 rpmte_N(rpmteObject * s)
00089         /*@*/
00090 {
00091     return Py_BuildValue("s", rpmteN(s->te));
00092 }
00093 
00094 /*@null@*/
00095 static PyObject *
00096 rpmte_E(rpmteObject * s)
00097         /*@*/
00098 {
00099     return Py_BuildValue("s", rpmteE(s->te));
00100 }
00101 
00102 /*@null@*/
00103 static PyObject *
00104 rpmte_V(rpmteObject * s)
00105         /*@*/
00106 {
00107     return Py_BuildValue("s", rpmteV(s->te));
00108 }
00109 
00110 /*@null@*/
00111 static PyObject *
00112 rpmte_R(rpmteObject * s)
00113         /*@*/
00114 {
00115     return Py_BuildValue("s", rpmteR(s->te));
00116 }
00117 
00118 /*@null@*/
00119 static PyObject *
00120 rpmte_A(rpmteObject * s)
00121         /*@*/
00122 {
00123     return Py_BuildValue("s", rpmteA(s->te));
00124 }
00125 
00126 /*@null@*/
00127 static PyObject *
00128 rpmte_O(rpmteObject * s)
00129         /*@*/
00130 {
00131     return Py_BuildValue("s", rpmteO(s->te));
00132 }
00133 
00134 /*@null@*/
00135 static PyObject *
00136 rpmte_NEVR(rpmteObject * s)
00137         /*@*/
00138 {
00139     return Py_BuildValue("s", rpmteNEVR(s->te));
00140 }
00141 
00142 /*@null@*/
00143 static PyObject *
00144 rpmte_NEVRA(rpmteObject * s)
00145         /*@*/
00146 {
00147     return Py_BuildValue("s", rpmteNEVRA(s->te));
00148 }
00149 
00150 /*@null@*/
00151 static PyObject *
00152 rpmte_Pkgid(rpmteObject * s)
00153         /*@*/
00154 {
00155     return Py_BuildValue("s", rpmtePkgid(s->te));
00156 }
00157 
00158 /*@null@*/
00159 static PyObject *
00160 rpmte_Hdrid(rpmteObject * s)
00161         /*@*/
00162 {
00163     return Py_BuildValue("s", rpmteHdrid(s->te));
00164 }
00165 
00166 /*@null@*/
00167 static PyObject *
00168 rpmte_Color(rpmteObject * s)
00169         /*@*/
00170 {
00171     return Py_BuildValue("i", rpmteColor(s->te));
00172 }
00173 
00174 /*@null@*/
00175 static PyObject *
00176 rpmte_PkgFileSize(rpmteObject * s)
00177         /*@*/
00178 {
00179     return Py_BuildValue("i", rpmtePkgFileSize(s->te));
00180 }
00181 
00182 /*@null@*/
00183 static PyObject *
00184 rpmte_Breadth(rpmteObject * s)
00185         /*@*/
00186 {
00187     return Py_BuildValue("i", rpmteBreadth(s->te));
00188 }
00189 
00190 /*@null@*/
00191 static PyObject *
00192 rpmte_Depth(rpmteObject * s)
00193         /*@*/
00194 {
00195     return Py_BuildValue("i", rpmteDepth(s->te));
00196 }
00197 
00198 /*@null@*/
00199 static PyObject *
00200 rpmte_Npreds(rpmteObject * s)
00201         /*@*/
00202 {
00203     return Py_BuildValue("i", rpmteNpreds(s->te));
00204 }
00205 
00206 /*@null@*/
00207 static PyObject *
00208 rpmte_Degree(rpmteObject * s)
00209         /*@*/
00210 {
00211     return Py_BuildValue("i", rpmteDegree(s->te));
00212 }
00213 
00214 /*@null@*/
00215 static PyObject *
00216 rpmte_Parent(rpmteObject * s)
00217         /*@*/
00218 {
00219     return Py_BuildValue("i", rpmteParent(s->te));
00220 }
00221 
00222 /*@null@*/
00223 static PyObject *
00224 rpmte_Tree(rpmteObject * s)
00225         /*@*/
00226 {
00227     return Py_BuildValue("i", rpmteTree(s->te));
00228 }
00229 
00230 /*@null@*/
00231 static PyObject *
00232 rpmte_AddedKey(rpmteObject * s)
00233         /*@*/
00234 {
00235     return Py_BuildValue("i", rpmteAddedKey(s->te));
00236 }
00237 
00238 /*@null@*/
00239 static PyObject *
00240 rpmte_DBOffset(rpmteObject * s)
00241         /*@*/
00242 {
00243     return Py_BuildValue("i", rpmteDBOffset(s->te));
00244 }
00245 
00246 /*@null@*/
00247 static PyObject *
00248 rpmte_Key(rpmteObject * s)
00249         /*@globals _Py_NoneStruct @*/
00250         /*@modifies _Py_NoneStruct @*/
00251 {
00252     PyObject * Key;
00253 
00254     /* XXX how to insure that returned Key is a PyObject??? */
00255     Key = (PyObject *) rpmteKey(s->te);
00256     if (Key == NULL)
00257         Key = Py_None;
00258     Py_INCREF(Key);
00259     return Key;
00260 }
00261 
00262 /*@null@*/
00263 static PyObject *
00264 rpmte_DS(rpmteObject * s, PyObject * args, PyObject * kwds)
00265         /*@globals _Py_NoneStruct @*/
00266         /*@modifies _Py_NoneStruct @*/
00267 {
00268     PyObject * TagN = NULL;
00269     rpmds ds;
00270     rpmTag tag;
00271     char * kwlist[] = {"tag", NULL};
00272 
00273     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:DS", kwlist, &TagN))
00274         return NULL;
00275 
00276     tag = tagNumFromPyObject(TagN);
00277     if (tag == -1) {
00278         PyErr_SetString(PyExc_TypeError, "unknown tag type");
00279         return NULL;
00280     }
00281 
00282     ds = rpmteDS(s->te, tag);
00283     if (ds == NULL) {
00284         Py_INCREF(Py_None);
00285         return Py_None;
00286     }
00287     return (PyObject *) rpmds_Wrap(rpmdsLink(ds, "rpmte_DS"));
00288 }
00289 
00290 /*@null@*/
00291 static PyObject *
00292 rpmte_FI(rpmteObject * s, PyObject * args, PyObject * kwds)
00293         /*@globals _Py_NoneStruct @*/
00294         /*@modifies _Py_NoneStruct @*/
00295 {
00296     PyObject * TagN = NULL;
00297     rpmfi fi;
00298     rpmTag tag;
00299     char * kwlist[] = {"tag", NULL};
00300 
00301     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:FI", kwlist, &TagN))
00302         return NULL;
00303 
00304     tag = tagNumFromPyObject(TagN);
00305     if (tag == -1) {
00306         PyErr_SetString(PyExc_TypeError, "unknown tag type");
00307         return NULL;
00308     }
00309 
00310     fi = rpmteFI(s->te, tag);
00311     if (fi == NULL) {
00312         Py_INCREF(Py_None);
00313         return Py_None;
00314     }
00315     return (PyObject *) rpmfi_Wrap(rpmfiLink(fi, "rpmte_FI"));
00316 }
00317 
00322 /*@-fullinitblock@*/
00323 /*@unchecked@*/ /*@observer@*/
00324 static struct PyMethodDef rpmte_methods[] = {
00325     {"Debug",   (PyCFunction)rpmte_Debug,       METH_VARARGS|METH_KEYWORDS,
00326         NULL},
00327     {"Type",    (PyCFunction)rpmte_TEType,      METH_NOARGS,
00328 "te.Type() -> Type\n\
00329 - Return element type (rpm.TR_ADDED | rpm.TR_REMOVED).\n" },
00330     {"N",       (PyCFunction)rpmte_N,           METH_NOARGS,
00331 "te.N() -> N\n\
00332 - Return element name.\n" },
00333     {"E",       (PyCFunction)rpmte_E,           METH_NOARGS,
00334 "te.E() -> E\n\
00335 - Return element epoch.\n" },
00336     {"V",       (PyCFunction)rpmte_V,           METH_NOARGS,
00337 "te.V() -> V\n\
00338 - Return element version.\n" },
00339     {"R",       (PyCFunction)rpmte_R,           METH_NOARGS,
00340 "te.R() -> R\n\
00341 - Return element release.\n" },
00342     {"A",       (PyCFunction)rpmte_A,           METH_NOARGS,
00343 "te.A() -> A\n\
00344 - Return element arch.\n" },
00345     {"O",       (PyCFunction)rpmte_O,           METH_NOARGS,
00346 "te.O() -> O\n\
00347 - Return element os.\n" },
00348     {"NEVR",    (PyCFunction)rpmte_NEVR,        METH_NOARGS,
00349 "te.NEVR() -> NEVR\n\
00350 - Return element name-version-release.\n" },
00351     {"NEVRA",   (PyCFunction)rpmte_NEVRA,       METH_NOARGS,
00352 "te.NEVRA() -> NEVRA\n\
00353 - Return element name-version-release.arch.\n" },
00354     {"Pkgid",   (PyCFunction)rpmte_Pkgid,       METH_NOARGS,
00355 "te.Pkgid() -> Pkgid\n\
00356 - Return element pkgid (header+payload md5 digest).\n" },
00357     {"Hdrid",   (PyCFunction)rpmte_Hdrid,       METH_NOARGS,
00358 "te.Hdrid() -> Hdrid\n\
00359 - Return element hdrid (header sha1 digest).\n" },
00360     {"Color",(PyCFunction)rpmte_Color,          METH_NOARGS,
00361         NULL},
00362     {"PkgFileSize",(PyCFunction)rpmte_PkgFileSize,      METH_NOARGS,
00363         NULL},
00364     {"Breadth", (PyCFunction)rpmte_Breadth,     METH_NOARGS,
00365 "te.Breadth() -> transaction element breadth index.\n" },
00366     {"Depth",   (PyCFunction)rpmte_Depth,       METH_NOARGS,
00367 "te.Depth() -> transaction element depth index.\n" },
00368     {"Npreds",  (PyCFunction)rpmte_Npreds,      METH_NOARGS,
00369         NULL},
00370     {"Degree",  (PyCFunction)rpmte_Degree,      METH_NOARGS,
00371         NULL},
00372     {"Parent",  (PyCFunction)rpmte_Parent,      METH_NOARGS,
00373         NULL},
00374     {"Tree",    (PyCFunction)rpmte_Tree,        METH_NOARGS,
00375         NULL},
00376     {"AddedKey",(PyCFunction)rpmte_AddedKey,    METH_NOARGS,
00377         NULL},
00378     {"DBOffset",(PyCFunction)rpmte_DBOffset,    METH_NOARGS,
00379         NULL},
00380     {"Key",     (PyCFunction)rpmte_Key,         METH_NOARGS,
00381         NULL},
00382     {"DS",      (PyCFunction)rpmte_DS,          METH_VARARGS|METH_KEYWORDS,
00383 "te.DS(TagN) -> DS\n\
00384 - Return the TagN dependency set (or None). TagN is one of\n\
00385         'Providename', 'Requirename', 'Obsoletename', 'Conflictname'\n" },
00386     {"FI",      (PyCFunction)rpmte_FI,          METH_VARARGS|METH_KEYWORDS,
00387 "te.FI(TagN) -> FI\n\
00388 - Return the TagN dependency set (or None). TagN must be 'Basenames'.\n" },
00389     {NULL,              NULL}           /* sentinel */
00390 };
00391 /*@=fullinitblock@*/
00392 
00393 /* ---------- */
00394 
00395 static int
00396 rpmte_print(rpmteObject * s, FILE * fp, /*@unused@*/ int flags)
00397         /*@globals fileSystem @*/
00398         /*@modifies fp, fileSystem @*/
00399 {
00400     const char * tstr;
00401     if (!(s && s->te))
00402         return -1;
00403     switch (rpmteType(s->te)) {
00404     case TR_ADDED:      tstr = "++";    break;
00405     case TR_REMOVED:    tstr = "--";    break;
00406     default:            tstr = "??";    break;
00407     }
00408     fprintf(fp, "%s %s %s", tstr, rpmteNEVR(s->te), rpmteA(s->te));
00409     return 0;
00410 }
00411 
00412 static PyObject * rpmte_getattro(PyObject * o, PyObject * n)
00413         /*@*/
00414 {
00415     return PyObject_GenericGetAttr(o, n);
00416 }
00417 
00418 static int rpmte_setattro(PyObject * o, PyObject * n, PyObject * v)
00419         /*@*/
00420 {
00421     return PyObject_GenericSetAttr(o, n, v);
00422 }
00423 
00426 /*@unchecked@*/ /*@observer@*/
00427 static char rpmte_doc[] =
00428 "";
00429 
00432 /*@-fullinitblock@*/
00433 PyTypeObject rpmte_Type = {
00434         PyObject_HEAD_INIT(&PyType_Type)
00435         0,                              /* ob_size */
00436         "rpm.te",                       /* tp_name */
00437         sizeof(rpmteObject),            /* tp_size */
00438         0,                              /* tp_itemsize */
00439         (destructor)0,                  /* tp_dealloc */
00440         (printfunc) rpmte_print,        /* tp_print */
00441         (getattrfunc)0,                 /* tp_getattr */
00442         (setattrfunc)0,                 /* tp_setattr */
00443         0,                              /* tp_compare */
00444         0,                              /* tp_repr */
00445         0,                              /* tp_as_number */
00446         0,                              /* tp_as_sequence */
00447         0,                              /* tp_as_mapping */
00448         0,                              /* tp_hash */
00449         0,                              /* tp_call */
00450         0,                              /* tp_str */
00451         (getattrofunc) rpmte_getattro,  /* tp_getattro */
00452         (setattrofunc) rpmte_setattro,  /* tp_setattro */
00453         0,                              /* tp_as_buffer */
00454         Py_TPFLAGS_DEFAULT,             /* tp_flags */
00455         rpmte_doc,                      /* tp_doc */
00456 #if Py_TPFLAGS_HAVE_ITER
00457         0,                              /* tp_traverse */
00458         0,                              /* tp_clear */
00459         0,                              /* tp_richcompare */
00460         0,                              /* tp_weaklistoffset */
00461         0,                              /* tp_iter */
00462         0,                              /* tp_iternext */
00463         rpmte_methods,                  /* tp_methods */
00464         0,                              /* tp_members */
00465         0,                              /* tp_getset */
00466         0,                              /* tp_base */
00467         0,                              /* tp_dict */
00468         0,                              /* tp_descr_get */
00469         0,                              /* tp_descr_set */
00470         0,                              /* tp_dictoffset */
00471         0,                              /* tp_init */
00472         0,                              /* tp_alloc */
00473         0,                              /* tp_new */
00474         0,                              /* tp_free */
00475         0,                              /* tp_is_gc */
00476 #endif
00477 };
00478 /*@=fullinitblock@*/
00479 
00480 rpmteObject * rpmte_Wrap(rpmte te)
00481 {
00482     rpmteObject *s = PyObject_New(rpmteObject, &rpmte_Type);
00483     if (s == NULL)
00484         return NULL;
00485     s->te = te;
00486     return s;
00487 }

Generated on Wed Feb 6 22:30:19 2008 for rpm by  doxygen 1.4.4