Revert the ds, ts, fi and spec python object creation commits
- Hasty push-finger syndrom, while its not exactly plain wrong to do things this way, it doesn't really make sense for these types either. Python's own file object permits reinitialization though, so leaving rpm.fd() the way it is now. - This reverts the following commits:d056df28c3
3f77c3146d
7214b2e0a2
dc50fb2863
This commit is contained in:
parent
ba2401f746
commit
a71a7981cc
|
@ -254,6 +254,12 @@ static PyMappingMethods rpmds_as_mapping = {
|
|||
(objobjargproc)0, /* mp_ass_subscript */
|
||||
};
|
||||
|
||||
static int rpmds_init(rpmdsObject * s, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
s->active = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int depflags(PyObject *o, rpmsenseFlags *senseFlags)
|
||||
{
|
||||
int ok = 0;
|
||||
|
@ -293,7 +299,7 @@ static int depflags(PyObject *o, rpmsenseFlags *senseFlags)
|
|||
return ok;
|
||||
}
|
||||
|
||||
static int rpmds_init(rpmdsObject *s, PyObject *args, PyObject *kwds)
|
||||
static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject *obj;
|
||||
rpmTagVal tagN = RPMTAG_REQUIRENAME;
|
||||
|
@ -303,7 +309,7 @@ static int rpmds_init(rpmdsObject *s, PyObject *args, PyObject *kwds)
|
|||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&:rpmds_new", kwlist,
|
||||
&obj, tagNumFromPyObject, &tagN))
|
||||
return -1;
|
||||
return NULL;
|
||||
|
||||
if (PyTuple_Check(obj)) {
|
||||
const char *name = NULL;
|
||||
|
@ -314,7 +320,7 @@ static int rpmds_init(rpmdsObject *s, PyObject *args, PyObject *kwds)
|
|||
ds = rpmdsSingle(tagN, name, evr, flags);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid dependency tuple");
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
} else if (hdrFromPyObject(obj, &h)) {
|
||||
if (tagN == RPMTAG_NEVR) {
|
||||
|
@ -324,14 +330,10 @@ static int rpmds_init(rpmdsObject *s, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "header or tuple expected");
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rpmdsFree(s->ds);
|
||||
s->ds = ds;
|
||||
s->active = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
return rpmds_Wrap(subtype, ds);
|
||||
}
|
||||
|
||||
static char rpmds_doc[] =
|
||||
|
@ -376,7 +378,7 @@ PyTypeObject rpmds_Type = {
|
|||
0, /* tp_dictoffset */
|
||||
(initproc) rpmds_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
(newfunc) rpmds_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
0, /* tp_is_gc */
|
||||
};
|
||||
|
|
|
@ -288,20 +288,26 @@ static PyMappingMethods rpmfi_as_mapping = {
|
|||
|
||||
static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject * to = NULL; /* unused */
|
||||
s->active = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyObject * to = NULL;
|
||||
Header h = NULL;
|
||||
rpmfi fi = NULL;
|
||||
rpmTagVal tagN = RPMTAG_BASENAMES;
|
||||
int flags = 0;
|
||||
char * kwlist[] = {"header", "tag", "flags", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|Oi:rpmfi_init", kwlist,
|
||||
hdrFromPyObject, &h, &to, &flags))
|
||||
return -1;
|
||||
return NULL;
|
||||
|
||||
rpmfiFree(s->fi);
|
||||
s->fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, flags);
|
||||
s->active = 0;
|
||||
fi = rpmfiNew(NULL, h, tagN, flags);
|
||||
|
||||
return 0;
|
||||
return rpmfi_Wrap(subtype, fi);
|
||||
}
|
||||
|
||||
static char rpmfi_doc[] =
|
||||
|
@ -346,11 +352,18 @@ PyTypeObject rpmfi_Type = {
|
|||
0, /* tp_dictoffset */
|
||||
(initproc) rpmfi_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
(newfunc) rpmfi_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
0, /* tp_is_gc */
|
||||
};
|
||||
|
||||
/* ---------- */
|
||||
|
||||
rpmfi fiFromFi(rpmfiObject * s)
|
||||
{
|
||||
return s->fi;
|
||||
}
|
||||
|
||||
PyObject * rpmfi_Wrap(PyTypeObject *subtype, rpmfi fi)
|
||||
{
|
||||
rpmfiObject *s = (rpmfiObject *)subtype->tp_alloc(subtype, 0);
|
||||
|
|
|
@ -9,6 +9,8 @@ extern PyTypeObject rpmfi_Type;
|
|||
|
||||
#define rpmfiObject_Check(v) ((v)->ob_type == &rpmfi_Type)
|
||||
|
||||
rpmfi fiFromFi(rpmfiObject * fi);
|
||||
|
||||
PyObject * rpmfi_Wrap(PyTypeObject *subtype, rpmfi fi);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -726,6 +726,18 @@ static void rpmts_dealloc(rpmtsObject * s)
|
|||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
rpmtsObject * s = (rpmtsObject *)subtype->tp_alloc(subtype, 0);
|
||||
if (s == NULL) return NULL;
|
||||
|
||||
s->ts = rpmtsCreate();
|
||||
s->scriptFd = NULL;
|
||||
s->tsi = NULL;
|
||||
s->keyList = PyList_New(0);
|
||||
return (PyObject *) s;
|
||||
}
|
||||
|
||||
static int rpmts_init(rpmtsObject *s, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
char * rootDir = "/";
|
||||
|
@ -736,16 +748,6 @@ static int rpmts_init(rpmtsObject *s, PyObject *args, PyObject *kwds)
|
|||
&rootDir, &vsflags))
|
||||
return -1;
|
||||
|
||||
rpmtsiFree(s->tsi);
|
||||
rpmtsFree(s->ts);
|
||||
Py_XDECREF(s->scriptFd);
|
||||
Py_XDECREF(s->keyList);
|
||||
|
||||
s->ts = rpmtsCreate();
|
||||
s->scriptFd = NULL;
|
||||
s->tsi = NULL;
|
||||
s->keyList = PyList_New(0);
|
||||
|
||||
(void) rpmtsSetRootDir(s->ts, rootDir);
|
||||
/* XXX: make this use common code with rpmts_SetVSFlags() to check the
|
||||
* python objects */
|
||||
|
@ -895,7 +897,7 @@ PyTypeObject rpmts_Type = {
|
|||
0, /* tp_dictoffset */
|
||||
(initproc) rpmts_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
(newfunc) rpmts_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
0, /* tp_is_gc */
|
||||
};
|
||||
|
|
|
@ -169,15 +169,6 @@ static PyObject * spec_get_sources(specObject *s, void *closure)
|
|||
|
||||
}
|
||||
|
||||
static PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
|
||||
{
|
||||
specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
|
||||
if (s == NULL) return NULL;
|
||||
|
||||
s->pkg = pkg;
|
||||
return (PyObject *) s;
|
||||
}
|
||||
|
||||
static PyObject * spec_get_packages(specObject *s, void *closure)
|
||||
{
|
||||
rpmSpecPkg pkg;
|
||||
|
@ -211,7 +202,7 @@ static PyGetSetDef spec_getseters[] = {
|
|||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
static int spec_init(specObject *self, PyObject *args, PyObject *kwds)
|
||||
static PyObject *spec_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
char * kwlist[] = {"specfile", "flags", NULL};
|
||||
const char * specfile;
|
||||
|
@ -221,17 +212,15 @@ static int spec_init(specObject *self, PyObject *args, PyObject *kwds)
|
|||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i:spec_new", kwlist,
|
||||
&specfile, &flags))
|
||||
return -1;
|
||||
return NULL;
|
||||
|
||||
spec = rpmSpecParse(specfile, flags, NULL);
|
||||
if (spec != NULL) {
|
||||
rpmSpecFree(self->spec);
|
||||
self->spec = spec;
|
||||
} else {
|
||||
if (spec == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "can't parse specfile\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (spec == NULL) ? -1 : 0;
|
||||
return spec_Wrap(subtype, spec);
|
||||
}
|
||||
|
||||
static PyObject * spec_doBuild(specObject *self, PyObject *args, PyObject *kwds)
|
||||
|
@ -287,10 +276,29 @@ PyTypeObject spec_Type = {
|
|||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
(initproc) spec_init, /* tp_init */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PyType_GenericNew, /* tp_new */
|
||||
spec_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
0, /* tp_is_gc */
|
||||
};
|
||||
|
||||
PyObject *
|
||||
spec_Wrap(PyTypeObject *subtype, rpmSpec spec)
|
||||
{
|
||||
specObject * s = (specObject *)subtype->tp_alloc(subtype, 0);
|
||||
if (s == NULL) return NULL;
|
||||
|
||||
s->spec = spec;
|
||||
return (PyObject *) s;
|
||||
}
|
||||
|
||||
PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg)
|
||||
{
|
||||
specPkgObject * s = (specPkgObject *)subtype->tp_alloc(subtype, 0);
|
||||
if (s == NULL) return NULL;
|
||||
|
||||
s->pkg = pkg;
|
||||
return (PyObject *) s;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,4 +12,7 @@ extern PyTypeObject specPkg_Type;
|
|||
#define specObject_Check(v) ((v)->ob_type == &spec_Type)
|
||||
#define specPkgObject_Check(v) ((v)->ob_type == &specPkg_Type)
|
||||
|
||||
PyObject * spec_Wrap(PyTypeObject *subtype, rpmSpec spec);
|
||||
PyObject * specPkg_Wrap(PyTypeObject *subtype, rpmSpecPkg pkg);
|
||||
|
||||
#endif /* RPMPYTHON_SPEC */
|
||||
|
|
Loading…
Reference in New Issue