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 #############################################################################*/
23 #include <solv/transaction.h>
27 #include "transaction.h"
29 PyTypeObject TransactionType
= {
30 PyObject_HEAD_INIT(NULL
)
31 tp_name
: "_pakfire.Transaction",
32 tp_basicsize
: sizeof(TransactionObject
),
33 tp_flags
: Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
,
34 tp_new
: Transaction_new
,
35 tp_dealloc
: (destructor
) Transaction_dealloc
,
36 tp_doc
: "Sat Transaction objects",
39 PyObject
* Transaction_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
) {
40 TransactionObject
*self
;
43 if (!PyArg_ParseTuple(args
, "O", &solver
)) {
44 /* XXX raise exception */
47 self
= (TransactionObject
*)type
->tp_alloc(type
, 0);
49 self
->_pool
= solver
->_solver
->pool
;
50 if (self
->_pool
== NULL
) {
55 // Create a new transaction from the solver and order it.
56 self
->_transaction
= solver_create_transaction(solver
->_solver
);
57 transaction_order(self
->_transaction
, 0);
60 return (PyObject
*)self
;
63 PyObject
*Transaction_dealloc(TransactionObject
*self
) {
64 /* XXX need to free self->_transaction */
65 self
->ob_type
->tp_free((PyObject
*)self
);
70 PyObject
*Transaction_steps(TransactionObject
*self
, PyObject
*args
) {
71 PyObject
*list
= PyList_New(0);
75 for(; i
< self
->_transaction
->steps
.count
; i
++) {
76 step
= PyObject_New(StepObject
, &StepType
);
77 step
->_transaction
= self
->_transaction
;
78 step
->_id
= self
->_transaction
->steps
.elements
[i
];
80 PyList_Append(list
, (PyObject
*)step
);
86 PyObject
*Transaction_get_installsizechange(TransactionObject
*self
) {
87 int installsizechange
= transaction_calc_installsizechange(self
->_transaction
);
89 return Py_BuildValue("i", installsizechange
* 1024);