1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2011 Pakfire development team #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 #############################################################################*/
26 PyTypeObject RelationType
= {
27 PyObject_HEAD_INIT(NULL
)
28 tp_name
: "_pakfire.Relation",
29 tp_basicsize
: sizeof(RelationObject
),
30 tp_flags
: Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
,
31 tp_new
: Relation_new
,
32 tp_dealloc
: (destructor
) Relation_dealloc
,
33 tp_doc
: "Sat Relation objects",
34 tp_str
: (reprfunc
)Relation_string
,
37 PyObject
* Relation_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
) {
41 const char *evr
= NULL
;
44 if (!PyArg_ParseTuple(args
, "Os|si", &pool
, &name
, &evr
, &flags
)) {
45 /* XXX raise exception */
49 Id _name
= pool_str2id(pool
->_pool
, name
, 1);
51 self
= (RelationObject
*)type
->tp_alloc(type
, 0);
53 if (flags
== REL_NONE
) {
56 Id _evr
= pool_str2id(pool
->_pool
, evr
, 1);
57 self
->_id
= pool_rel2id(pool
->_pool
, _name
, _evr
, flags
, 1);
60 self
->_pool
= pool
->_pool
;
63 return (PyObject
*)self
;
66 PyObject
*Relation_dealloc(RelationObject
*self
) {
67 self
->ob_type
->tp_free((PyObject
*)self
);
72 PyObject
*Relation_string(RelationObject
*self
) {
73 return Py_BuildValue("s", pool_dep2str(self
->_pool
, self
->_id
));