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 "transaction.h"
25 PyTypeObject StepType
= {
26 PyObject_HEAD_INIT(NULL
)
27 tp_name
: "_pakfire.Step",
28 tp_basicsize
: sizeof(StepObject
),
29 tp_flags
: Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
,
31 tp_dealloc
: (destructor
) Step_dealloc
,
32 tp_doc
: "Sat Step objects",
35 PyObject
* Step_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwds
) {
37 TransactionObject
*transaction
;
40 if (!PyArg_ParseTuple(args
, "Oi", &transaction
, &num
)) {
41 /* XXX raise exception */
44 self
= (StepObject
*)type
->tp_alloc(type
, 0);
46 self
->_transaction
= transaction
->_transaction
;
48 if (num
>= transaction
->_transaction
->steps
.count
) {
53 self
->_id
= transaction
->_transaction
->steps
.elements
[num
];
56 return (PyObject
*)self
;
59 PyObject
*Step_dealloc(StepObject
*self
) {
60 self
->ob_type
->tp_free((PyObject
*)self
);
65 PyObject
*Step_get_solvable(StepObject
*self
, PyObject
*args
) {
66 SolvableObject
*solvable
;
68 solvable
= PyObject_New(SolvableObject
, &SolvableType
);
72 solvable
->_pool
= self
->_transaction
->pool
;
73 solvable
->_id
= self
->_id
;
75 return (PyObject
*)solvable
;
78 PyObject
*Step_get_type(StepObject
*self
, PyObject
*args
) {
79 const char *type
= "unknown";
81 int trans_type
= transaction_type(self
->_transaction
, self
->_id
,
82 SOLVER_TRANSACTION_SHOW_ACTIVE
|SOLVER_TRANSACTION_CHANGE_IS_REINSTALL
);
85 case SOLVER_TRANSACTION_IGNORE
:
89 case SOLVER_TRANSACTION_ERASE
:
93 case SOLVER_TRANSACTION_REINSTALLED
:
97 case SOLVER_TRANSACTION_DOWNGRADED
:
101 case SOLVER_TRANSACTION_CHANGED
:
105 case SOLVER_TRANSACTION_UPGRADED
:
109 case SOLVER_TRANSACTION_OBSOLETED
:
113 case SOLVER_TRANSACTION_INSTALL
:
117 case SOLVER_TRANSACTION_REINSTALL
:
121 case SOLVER_TRANSACTION_DOWNGRADE
:
125 case SOLVER_TRANSACTION_CHANGE
:
129 case SOLVER_TRANSACTION_UPGRADE
:
133 case SOLVER_TRANSACTION_OBSOLETES
:
137 case SOLVER_TRANSACTION_MULTIINSTALL
:
138 type
= "multiinstall";
141 case SOLVER_TRANSACTION_MULTIREINSTALL
:
142 type
= "multireinstall";
149 return Py_BuildValue("s", type
);