1) added sprintf method to headers
authorjbj <devnull@localhost>
Mon, 4 Feb 2002 18:07:52 +0000 (18:07 +0000)
committerjbj <devnull@localhost>
Mon, 4 Feb 2002 18:07:52 +0000 (18:07 +0000)
2) added setVerbosity()

CVS patchset: 5298
CVS date: 2002/02/04 18:07:52

python/rpmmodule.c

index ad4767d..1f97462 100644 (file)
@@ -109,7 +109,9 @@ static PyObject * pyrpmError;
  *     print header['name']
  * \endcode
  * This method of access is a bit slower because the name must be
- * translated into the tag number dynamically.
+ * translated into the tag number dynamically. You also must make sure
+ * the strings in header lookups don't get translated, or the lookups
+ * will fail.
  */
 
 /** \ingroup python
@@ -513,6 +515,9 @@ static PyObject * rhnUnload(hdrObject * s, PyObject * args) {
 /** \ingroup python
  */
 static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) {
+    if (!PyArg_ParseTuple(args, ""))
+       return NULL;
+
     mungeFilelist (s->h);
 
     Py_INCREF(Py_None);
@@ -521,6 +526,30 @@ static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) {
 
 /** \ingroup python
  */
+static PyObject * hdrSprintf(hdrObject * s, PyObject * args) {
+    char * fmt;
+    char * r;
+    errmsg_t err;
+    PyObject * result;
+
+    if (!PyArg_ParseTuple(args, "s", &fmt))
+       return NULL;
+
+    r = headerSprintf(s->h, fmt, rpmTagTable, rpmHeaderFormats, &err);
+    if (!r) {
+       PyErr_SetString(pyrpmError, err);
+       return NULL;
+    }
+
+    result = Py_BuildValue("s", r);
+    free(r);
+
+    return result;
+}
+
+
+/** \ingroup python
+ */
 static struct PyMethodDef hdrMethods[] = {
        {"keys",        (PyCFunction) hdrKeyList,       1 },
        {"unload",      (PyCFunction) hdrUnload,        METH_VARARGS|METH_KEYWORDS },
@@ -529,6 +558,7 @@ static struct PyMethodDef hdrMethods[] = {
        {"compressFilelist",    (PyCFunction) hdrCompressFilelist,      1 },
        {"fullFilelist",        (PyCFunction) hdrFullFilelist,  1 },
        {"rhnUnload",   (PyCFunction) rhnUnload, METH_VARARGS },
+       {"sprintf",     (PyCFunction) hdrSprintf, METH_VARARGS },
        {NULL,          NULL}           /* sentinel */
 };
 
@@ -2363,6 +2393,9 @@ static PyObject * checkSig (PyObject * self, PyObject * args) {
  */
 static PyObject * getTsHeader (PyObject * self, PyObject * args) {
     hdrObject * h;
+
+    if (!PyArg_ParseTuple(args, ""))
+       return NULL;
     
     if (transactionSetHeader) {
        h = (hdrObject *) PyObject_NEW(PyObject, &hdrType);
@@ -2376,6 +2409,18 @@ static PyObject * getTsHeader (PyObject * self, PyObject * args) {
     return (PyObject *) Py_None;
 }
 
+static PyObject * setVerbosity (PyObject * self, PyObject * args) {
+    int level;
+
+    if (!PyArg_ParseTuple(args, "i", &level))
+       return NULL;
+
+    rpmSetVerbosity(level);
+
+    Py_INCREF(Py_None);
+    return (PyObject *) Py_None;
+}
+
 /**
  */
 typedef struct FDlist_t FDlist;
@@ -2501,7 +2546,8 @@ static PyMethodDef rpmModuleMethods[] = {
     { "labelCompare", (PyCFunction) labelCompare, METH_VARARGS, NULL },
     { "checksig", (PyCFunction) checkSig, METH_VARARGS, NULL },
     { "getTransactionCallbackHeader", (PyCFunction) getTsHeader, METH_VARARGS, NULL },
-/*      { "Fopen", (PyCFunction) doFopen, METH_VARARGS, NULL }, */
+    { "Fopen", (PyCFunction) doFopen, METH_VARARGS, NULL },
+    { "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS, NULL },
     { NULL }
 } ;
 
@@ -2652,6 +2698,16 @@ void initrpm(void) {
     REGISTER_ENUM(VERIFY_DIGEST);
     REGISTER_ENUM(VERIFY_SIGNATURE);
 #endif
+
+    REGISTER_ENUM(RPMLOG_EMERG);
+    REGISTER_ENUM(RPMLOG_ALERT);
+    REGISTER_ENUM(RPMLOG_CRIT);
+    REGISTER_ENUM(RPMLOG_ERR);
+    REGISTER_ENUM(RPMLOG_WARNING);
+    REGISTER_ENUM(RPMLOG_NOTICE);
+    REGISTER_ENUM(RPMLOG_INFO);
+    REGISTER_ENUM(RPMLOG_DEBUG);
+
 }
 
 /*@}*/