* \name Class: rpm.hdr
*/
-#define DEPRECATED_METHOD \
- static int _warn = 0; \
- if (!_warn) PyErr_Warn(PyExc_DeprecationWarning, "method is deprecated"); \
- _warn = 1;
-
struct hdrObject_s {
PyObject_HEAD
Header h;
#define hdrObject_Check(v) ((v)->ob_type == &hdr_Type)
+#define DEPRECATED_METHOD \
+ static int _warn = 0; \
+ if (!_warn) PyErr_Warn(PyExc_DeprecationWarning, "method is deprecated"); \
+ _warn = 1;
+
extern PyObject * pyrpmError;
PyObject * hdr_Wrap(Header h);
static PyObject *
spec_Parse(rpmtsObject * s, PyObject * args, PyObject * kwds)
{
- const char * specfile;
- rpmSpec spec;
- char * buildRoot = NULL;
- int recursing = 0;
- char * passPhrase = "";
- char *cookie = NULL;
- int anyarch = 1;
- int force = 1;
- char * kwlist[] = {"specfile", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:Parse", kwlist, &specfile))
- return NULL;
-
- if (parseSpec(s->ts, specfile,"/", buildRoot,recursing, passPhrase,
- cookie, anyarch, force)!=0) {
- PyErr_SetString(pyrpmError, "can't parse specfile\n");
- return NULL;
- }
-
- spec = rpmtsSpec(s->ts);
- return spec_Wrap(spec);
+ DEPRECATED_METHOD;
+ /* we could pass in the ts from here but hardly worth the trouble */
+ return PyObject_Call((PyObject *) &spec_Type, args, kwds);
}
static PyObject *
#include "rpmsystem-py.h"
+#include "header-py.h"
#include "spec-py.h"
/** \ingroup python
* \code
* import rpm
* rpm.addMacro("_topdir","/path/to/topdir")
- * ts=rpm.ts()
- * s=ts.parseSpec("foo.spec")
+ * s=rpm.spec("foo.spec")
* print s.prep()
* \endcode
*
{NULL} /* Sentinel */
};
+static PyObject *spec_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
+{
+ rpmts ts = NULL;
+ const char * specfile;
+ rpmSpec spec = NULL;
+ char * buildRoot = NULL;
+ int recursing = 0;
+ char * passPhrase = "";
+ char *cookie = NULL;
+ int anyarch = 1;
+ int force = 1;
+ char * kwlist[] = {"specfile", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:spec_new", kwlist,
+ &specfile))
+ return NULL;
+
+ /*
+ * Just how hysterical can you get? We need to create a transaction
+ * set to get back the results from parseSpec()...
+ */
+ ts = rpmtsCreate();
+ if (parseSpec(ts, specfile,"/", buildRoot,recursing, passPhrase,
+ cookie, anyarch, force) == 0) {
+ spec = rpmtsSpec(ts);
+ } else {
+ PyErr_SetString(pyrpmError, "can't parse specfile\n");
+ }
+ rpmtsFree(ts);
+
+ return spec ? spec_Wrap(spec) : NULL;
+}
+
PyTypeObject spec_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- 0, /* tp_new */
+ spec_new, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
};