summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-02-04 18:07:52 +0000
committerjbj <devnull@localhost>2002-02-04 18:07:52 +0000
commit14bdb24e993893d0a65cf14956c00eb7d1edb02b (patch)
tree0cb51ade711254a70d7b66148d5d428cbbebfe04 /python
parent696c5d9d67e4bde344b921c94ffad5a8ad075ce8 (diff)
downloadrpm-14bdb24e993893d0a65cf14956c00eb7d1edb02b.tar.gz
rpm-14bdb24e993893d0a65cf14956c00eb7d1edb02b.tar.bz2
rpm-14bdb24e993893d0a65cf14956c00eb7d1edb02b.zip
1) added sprintf method to headers
2) added setVerbosity() CVS patchset: 5298 CVS date: 2002/02/04 18:07:52
Diffstat (limited to 'python')
-rw-r--r--python/rpmmodule.c60
1 files changed, 58 insertions, 2 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index ad4767df8..1f97462ac 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -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);
+
}
/*@}*/