]>
git.ipfire.org Git - pakfire.git/blob - python/src/request.c
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_push2(&self
->_queue
, what
|SOLVER_SOLVABLE
, solvable
);
70 void _Request_relation(RequestObject
*self
, Id what
, Id relation
) {
71 queue_push2(&self
->_queue
, what
|SOLVER_SOLVABLE_PROVIDES
, relation
);
74 void _Request_name(RequestObject
*self
, Id what
, Id provides
) {
75 queue_push2(&self
->_queue
, what
|SOLVER_SOLVABLE_NAME
, provides
);
78 PyObject
*Request_install_solvable(RequestObject
*self
, PyObject
*args
) {
81 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
85 _Request_solvable(self
, SOLVER_INSTALL
, solv
->_id
);
89 PyObject
*Request_install_relation(RequestObject
*self
, PyObject
*args
) {
92 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
96 _Request_relation(self
, SOLVER_INSTALL
, rel
->_id
);
100 PyObject
*Request_install_name(RequestObject
*self
, PyObject
*args
) {
103 if (!PyArg_ParseTuple(args
, "s", &name
)) {
107 Id _name
= pool_str2id(self
->_pool
, name
, 1);
108 _Request_name(self
, SOLVER_INSTALL
, _name
);
113 PyObject
*Request_remove_solvable(RequestObject
*self
, PyObject
*args
) {
114 SolvableObject
*solv
;
116 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
120 _Request_solvable(self
, SOLVER_ERASE
, solv
->_id
);
124 PyObject
*Request_remove_relation(RequestObject
*self
, PyObject
*args
) {
127 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
131 _Request_relation(self
, SOLVER_ERASE
, rel
->_id
);
135 PyObject
*Request_remove_name(RequestObject
*self
, PyObject
*args
) {
138 if (!PyArg_ParseTuple(args
, "s", &name
)) {
142 Id _name
= pool_str2id(self
->_pool
, name
, 1);
143 _Request_name(self
, SOLVER_ERASE
, _name
);
148 PyObject
*Request_update_solvable(RequestObject
*self
, PyObject
*args
) {
149 SolvableObject
*solv
;
151 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
155 _Request_solvable(self
, SOLVER_UPDATE
, solv
->_id
);
159 PyObject
*Request_update_relation(RequestObject
*self
, PyObject
*args
) {
162 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
166 _Request_relation(self
, SOLVER_UPDATE
, rel
->_id
);
170 PyObject
*Request_update_name(RequestObject
*self
, PyObject
*args
) {
173 if (!PyArg_ParseTuple(args
, "s", &name
)) {
177 Id _name
= pool_str2id(self
->_pool
, name
, 1);
178 _Request_name(self
, SOLVER_UPDATE
, _name
);
183 PyObject
*Request_lock_solvable(RequestObject
*self
, PyObject
*args
) {
184 SolvableObject
*solv
;
186 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
190 _Request_solvable(self
, SOLVER_LOCK
, solv
->_id
);
194 PyObject
*Request_lock_relation(RequestObject
*self
, PyObject
*args
) {
197 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
201 _Request_relation(self
, SOLVER_LOCK
, rel
->_id
);
205 PyObject
*Request_lock_name(RequestObject
*self
, PyObject
*args
) {
208 if (!PyArg_ParseTuple(args
, "s", &name
)) {
212 Id _name
= pool_str2id(self
->_pool
, name
, 1);
213 _Request_name(self
, SOLVER_LOCK
, _name
);
218 PyObject
*Request_noobsoletes_solvable(RequestObject
*self
, PyObject
*args
) {
219 SolvableObject
*solv
;
221 if (!PyArg_ParseTuple(args
, "O", &solv
)) {
225 _Request_solvable(self
, SOLVER_NOOBSOLETES
, solv
->_id
);
229 PyObject
*Request_noobsoletes_relation(RequestObject
*self
, PyObject
*args
) {
232 if (!PyArg_ParseTuple(args
, "O", &rel
)) {
236 _Request_relation(self
, SOLVER_NOOBSOLETES
, rel
->_id
);
240 PyObject
*Request_noobsoletes_name(RequestObject
*self
, PyObject
*args
) {
243 if (!PyArg_ParseTuple(args
, "s", &name
)) {
247 Id _name
= pool_str2id(self
->_pool
, name
, 1);
248 _Request_name(self
, SOLVER_NOOBSOLETES
, _name
);
253 PyObject
*Request_updateall(RequestObject
*self
, PyObject
*args
) {
254 queue_push2(&self
->_queue
, SOLVER_UPDATE
|SOLVER_SOLVABLE_ALL
, 0);
258 PyObject
*Request_distupgrade(RequestObject
*self
, PyObject
*args
) {
259 queue_push2(&self
->_queue
, SOLVER_DISTUPGRADE
|SOLVER_SOLVABLE_ALL
, 0);
263 PyObject
*Request_verify(RequestObject
*self
, PyObject
*args
) {
264 queue_push2(&self
->_queue
, SOLVER_VERIFY
|SOLVER_SOLVABLE_ALL
, 0);