]>
git.ipfire.org Git - pakfire.git/blob - python/src/request.c
168b455a00286345e22ae55fee007e81bb326bb0
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 #include <solv/solver.h>
28 PyTypeObject RequestType
= {
29 PyObject_HEAD_INIT(NULL
)
30 tp_name
: "_pakfire.Request",
31 tp_basicsize
: sizeof(RequestObject
),
32 tp_flags
: Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
,
34 tp_dealloc
: (destructor
) Request_dealloc
,
35 tp_doc
: "Sat Request objects",
38 PyObject
* Request_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
) {
42 if (!PyArg_ParseTuple(args
, "O", &pool
)) {
43 /* XXX raise exception */
46 self
= (RequestObject
*)type
->tp_alloc(type
, 0);
48 self
->_pool
= pool
->_pool
;
49 if (self
->_pool
== NULL
) {
54 queue_init(&self
->_queue
);
57 return (PyObject
*)self
;
60 PyObject
*Request_dealloc(RequestObject
*self
) {
61 self
->ob_type
->tp_free((PyObject
*)self
);
66 void _Request_solvable(RequestObject
*self
, Id what
, Id solvable
) {
67 queue_push(&self
->_queue
, what
|SOLVER_SOLVABLE
);
68 queue_push(&self
->_queue
, solvable
);
71 void _Request_relation(RequestObject
*self
, Id what
, Id relation
) {
72 queue_push(&self
->_queue
, what
|SOLVER_SOLVABLE_PROVIDES
);
73 queue_push(&self
->_queue
, relation
);
76 void _Request_name(RequestObject
*self
, Id what
, Id provides
) {
77 queue_push(&self
->_queue
, what
|SOLVER_SOLVABLE_NAME
);
78 queue_push(&self
->_queue
, provides
);
81 PyObject
*Request_install_solvable(RequestObject
*self
, PyObject
*args
) {
84 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
85 /* XXX raise exception */
88 _Request_solvable(self
, SOLVER_INSTALL
, solv
->_id
);
93 PyObject
*Request_install_relation(RequestObject
*self
, PyObject
*args
) {
96 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
97 /* XXX raise exception */
100 _Request_relation(self
, SOLVER_INSTALL
, rel
->_id
);
105 PyObject
*Request_install_name(RequestObject
*self
, PyObject
*args
) {
108 if (!PyArg_ParseTuple(args
, "s", &name
)) {
109 /* XXX raise exception */
112 Id _name
= pool_str2id(self
->_pool
, name
, 1);
113 _Request_name(self
, SOLVER_INSTALL
, _name
);
118 PyObject
*Request_remove_solvable(RequestObject
*self
, PyObject
*args
) {
119 SolvableObject
*solv
;
121 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
122 /* XXX raise exception */
125 _Request_solvable(self
, SOLVER_ERASE
, solv
->_id
);
130 PyObject
*Request_remove_relation(RequestObject
*self
, PyObject
*args
) {
133 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
134 /* XXX raise exception */
137 _Request_relation(self
, SOLVER_ERASE
, rel
->_id
);
142 PyObject
*Request_remove_name(RequestObject
*self
, PyObject
*args
) {
145 if (!PyArg_ParseTuple(args
, "s", &name
)) {
146 /* XXX raise exception */
149 Id _name
= pool_str2id(self
->_pool
, name
, 1);
150 _Request_name(self
, SOLVER_ERASE
, _name
);
155 PyObject
*Request_update_solvable(RequestObject
*self
, PyObject
*args
) {
156 SolvableObject
*solv
;
158 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
159 /* XXX raise exception */
162 _Request_solvable(self
, SOLVER_UPDATE
, solv
->_id
);
167 PyObject
*Request_update_relation(RequestObject
*self
, PyObject
*args
) {
170 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
171 /* XXX raise exception */
174 _Request_relation(self
, SOLVER_UPDATE
, rel
->_id
);
179 PyObject
*Request_update_name(RequestObject
*self
, PyObject
*args
) {
182 if (!PyArg_ParseTuple(args
, "s", &name
)) {
183 /* XXX raise exception */
186 Id _name
= pool_str2id(self
->_pool
, name
, 1);
187 _Request_name(self
, SOLVER_UPDATE
, _name
);
192 PyObject
*Request_lock_solvable(RequestObject
*self
, PyObject
*args
) {
193 SolvableObject
*solv
;
195 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
196 /* XXX raise exception */
199 _Request_solvable(self
, SOLVER_LOCK
, solv
->_id
);
204 PyObject
*Request_lock_relation(RequestObject
*self
, PyObject
*args
) {
207 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
208 /* XXX raise exception */
211 _Request_relation(self
, SOLVER_LOCK
, rel
->_id
);
216 PyObject
*Request_lock_name(RequestObject
*self
, PyObject
*args
) {
219 if (!PyArg_ParseTuple(args
, "s", &name
)) {
220 /* XXX raise exception */
223 Id _name
= pool_str2id(self
->_pool
, name
, 1);
224 _Request_name(self
, SOLVER_LOCK
, _name
);
229 PyObject
*Request_noobsoletes_solvable(RequestObject
*self
, PyObject
*args
) {
230 SolvableObject
*solv
;
232 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
233 /* XXX raise exception */
236 _Request_solvable(self
, SOLVER_NOOBSOLETES
, solv
->_id
);
241 PyObject
*Request_noobsoletes_relation(RequestObject
*self
, PyObject
*args
) {
244 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
245 /* XXX raise exception */
248 _Request_relation(self
, SOLVER_NOOBSOLETES
, rel
->_id
);
253 PyObject
*Request_noobsoletes_name(RequestObject
*self
, PyObject
*args
) {
256 if (!PyArg_ParseTuple(args
, "s", &name
)) {
257 /* XXX raise exception */
260 Id _name
= pool_str2id(self
->_pool
, name
, 1);
261 _Request_name(self
, SOLVER_NOOBSOLETES
, _name
);