Add hdr.format(), deprecate hdr.sprintf()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 23 Sep 2009 07:31:46 +0000 (10:31 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 23 Sep 2009 07:31:46 +0000 (10:31 +0300)
- sprintf() is a C'ism and format() is closer to current librpm anyway

python/header-py.c

index 21a10bb..2ed8a7d 100644 (file)
@@ -241,7 +241,7 @@ static PyObject * hdrFullFilelist(hdrObject * s)
     Py_RETURN_NONE;
 }
 
-static PyObject * hdrSprintf(hdrObject * s, PyObject * args, PyObject * kwds)
+static PyObject * hdrFormat(hdrObject * s, PyObject * args, PyObject * kwds)
 {
     char * fmt;
     char * r;
@@ -264,6 +264,12 @@ static PyObject * hdrSprintf(hdrObject * s, PyObject * args, PyObject * kwds)
     return result;
 }
 
+static PyObject * hdrSprintf(hdrObject * s, PyObject * args, PyObject * kwds)
+{
+    DEPRECATED_METHOD;
+    return hdrFormat(s, args, kwds);
+}
+
 static PyObject *hdrIsSource(hdrObject *s)
 {
     return PyBool_FromLong(headerIsSource(s->h));
@@ -319,6 +325,8 @@ static struct PyMethodDef hdr_methods[] = {
        NULL },
     {"convert",                (PyCFunction) hdrConvert,       METH_VARARGS|METH_KEYWORDS,
        NULL },
+    {"format",         (PyCFunction) hdrFormat,        METH_VARARGS|METH_KEYWORDS,
+       NULL },
     {"has_key",                (PyCFunction) hdrHasKey,        METH_O,
        NULL },
     {"sprintf",                (PyCFunction) hdrSprintf,       METH_VARARGS|METH_KEYWORDS,