From: Michael Tremer Date: Tue, 27 Apr 2021 16:46:56 +0000 (+0000) Subject: python: Drop step X-Git-Tag: 0.9.28~1285^2~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be5db0719c6db664dad1c6273e010b60ae1ef894;p=pakfire.git python: Drop step Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 966faec0b..47661d60b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -182,8 +182,6 @@ _pakfire_la_SOURCES = \ src/_pakfire/request.h \ src/_pakfire/solution.c \ src/_pakfire/solution.h \ - src/_pakfire/step.c \ - src/_pakfire/step.h \ src/_pakfire/transaction.c \ src/_pakfire/transaction.h \ src/_pakfire/util.c \ diff --git a/src/_pakfire/_pakfiremodule.c b/src/_pakfire/_pakfiremodule.c index 937c843c7..445f047ac 100644 --- a/src/_pakfire/_pakfiremodule.c +++ b/src/_pakfire/_pakfiremodule.c @@ -42,7 +42,6 @@ #include "repo.h" #include "request.h" #include "solution.h" -#include "step.h" #include "transaction.h" #include "util.h" @@ -185,13 +184,6 @@ PyMODINIT_FUNC PyInit__pakfire(void) { Py_INCREF(&SolutionType); PyModule_AddObject(module, "Solution", (PyObject *)&SolutionType); - // Step - if (PyType_Ready(&StepType) < 0) - return NULL; - - Py_INCREF(&StepType); - PyModule_AddObject(module, "Step", (PyObject *)&StepType); - // Transaction if (PyType_Ready(&TransactionType) < 0) return NULL; @@ -199,13 +191,6 @@ PyMODINIT_FUNC PyInit__pakfire(void) { Py_INCREF(&TransactionType); PyModule_AddObject(module, "Transaction", (PyObject *)&TransactionType); - // Transaction Iterator - if (PyType_Ready(&TransactionIteratorType) < 0) - return NULL; - - Py_INCREF(&TransactionIteratorType); - PyModule_AddObject(module, "TransactionIterator", (PyObject *)&TransactionIteratorType); - // Add constants for packages if (PyModule_AddIntConstant(module, "PAKFIRE_PKG_GROUP", PAKFIRE_PKG_GROUP)) return NULL; diff --git a/src/_pakfire/step.c b/src/_pakfire/step.c deleted file mode 100644 index 80d795a85..000000000 --- a/src/_pakfire/step.c +++ /dev/null @@ -1,186 +0,0 @@ -/*############################################################################# -# # -# Pakfire - The IPFire package management system # -# Copyright (C) 2011 Pakfire development team # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -#############################################################################*/ - -#include - -#include -#include -#include -#include - -#include "package.h" -#include "step.h" -#include "transaction.h" - -static StepObject* Step_new_core(PyTypeObject* type, TransactionObject* transaction) { - StepObject* self = (StepObject *)type->tp_alloc(type, 0); - if (!self) - return NULL; - - if (transaction) { - self->transaction = transaction; - Py_INCREF(self->transaction); - } - - self->step = NULL; - - return self; -} - -PyObject* new_step(TransactionObject* transaction, PakfireStep s) { - StepObject* step = Step_new_core(&StepType, transaction); - step->step = s; - - return (PyObject *)step; -} - -static PyObject* Step_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { - StepObject* self = Step_new_core(type, NULL); - - return (PyObject *)self; -} - -static void Step_dealloc(StepObject* self) { - pakfire_step_unref(self->step); - - Py_XDECREF(self->transaction); - Py_TYPE(self)->tp_free((PyObject *)self); -} - -static int Step_init(StepObject* self, PyObject* args, PyObject* kwds) { - TransactionObject* transaction; - int index = 0; - - if (!PyArg_ParseTuple(args, "O!i", &TransactionType, &transaction, &index)) - return -1; - - self->transaction = transaction; - Py_INCREF(self->transaction); - - self->step = pakfire_transaction_get_step(transaction->transaction, index); - if (!self->step) { - PyErr_SetString(PyExc_AttributeError, "No such step"); - return -1; - } - - return 0; -} - -static PyObject* Step_repr(StepObject* self) { - PakfirePackage package = pakfire_step_get_package(self->step); - char* nevra = pakfire_package_get_nevra(package); - - PyObject* repr = PyUnicode_FromFormat("<_pakfire.Step object type %s, %s>", - pakfire_step_get_type_string(self->step), nevra); - - pakfire_package_unref(package); - free(nevra); - - return repr; -} - -static PyObject* Step_get_package(StepObject* self) { - PakfirePackage package = pakfire_step_get_package(self->step); - - PyObject* obj = new_package(&PackageType, package); - pakfire_package_unref(package); - - return obj; -} - -static PyObject* Step_get_type(StepObject* self) { - const char* type = pakfire_step_get_type_string(self->step); - - if (!type) - Py_RETURN_NONE; - - return PyUnicode_FromString(type); -} - -static PyObject* Step_get_downloadsize(StepObject* self) { - unsigned long long downloadsize = pakfire_step_get_downloadsize(self->step); - - return PyLong_FromUnsignedLongLong(downloadsize); -} - -static PyObject* Step_get_installsizechange(StepObject* self) { - long installsizechange = pakfire_step_get_installsizechange(self->step); - - return PyLong_FromLong(installsizechange); -} - -static PyObject* Step_needs_download(StepObject* self) { - if (pakfire_step_needs_download(self->step)) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; -} - -static struct PyGetSetDef Step_getsetters[] = { - { - "downloadsize", - (getter)Step_get_downloadsize, - NULL, - NULL, - NULL - }, - { - "installsizechange", - (getter)Step_get_installsizechange, - NULL, - NULL, - NULL - }, - { - "needs_download", - (getter)Step_needs_download, - NULL, - NULL, - NULL - }, - { - "package", - (getter)Step_get_package, - NULL, - NULL, - NULL - }, - { - "type", - (getter)Step_get_type, - NULL, - NULL, - NULL - }, - { NULL }, -}; - -PyTypeObject StepType = { - PyVarObject_HEAD_INIT(NULL, 0) - tp_name: "_pakfire.Step", - tp_basicsize: sizeof(StepObject), - tp_flags: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, - tp_new: Step_new, - tp_dealloc: (destructor)Step_dealloc, - tp_init: (initproc)Step_init, - tp_doc: "Step object", - tp_repr: (reprfunc)Step_repr, - tp_getset: Step_getsetters, -}; diff --git a/src/_pakfire/step.h b/src/_pakfire/step.h deleted file mode 100644 index f218318b5..000000000 --- a/src/_pakfire/step.h +++ /dev/null @@ -1,40 +0,0 @@ -/*############################################################################# -# # -# Pakfire - The IPFire package management system # -# Copyright (C) 2011 Pakfire development team # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -#############################################################################*/ - -#ifndef PYTHON_PAKFIRE_STEP_H -#define PYTHON_PAKFIRE_STEP_H - -#include - -#include - -#include "transaction.h" - -typedef struct { - PyObject_HEAD - TransactionObject* transaction; - PakfireStep step; -} StepObject; - -extern PyTypeObject StepType; - -PyObject* new_step(TransactionObject* transaction, PakfireStep step); - -#endif /* PYTHON_PAKFIRE_STEP_H */ diff --git a/src/_pakfire/transaction.c b/src/_pakfire/transaction.c index a115e14aa..f5dc8b8cf 100644 --- a/src/_pakfire/transaction.c +++ b/src/_pakfire/transaction.c @@ -84,17 +84,6 @@ static int Transaction_init(TransactionObject* self, PyObject* args, PyObject* k return 0; } -static PyObject* Transaction_iter(TransactionObject* self) { - TransactionIteratorObject* iterator = PyObject_New(TransactionIteratorObject, &TransactionIteratorType); - - iterator->transaction = self; - Py_INCREF(iterator->transaction); - - iterator->iterator = 0; - - return (PyObject *)iterator; -} - static PyObject* Transaction_get_installsizechange(TransactionObject* self) { long installsizechange = pakfire_transaction_installsizechange(self->transaction); @@ -181,55 +170,5 @@ PyTypeObject TransactionType = { tp_doc: "Transaction object", tp_methods: Transaction_methods, tp_getset: Transaction_getsetters, - tp_iter: (getiterfunc)Transaction_iter, tp_as_sequence: &Transaction_sequence, }; - -static PyObject* TransactionIterator_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { - TransactionIteratorObject* self = (TransactionIteratorObject *)type->tp_alloc(type, 0); - - if (self) { - self->transaction = NULL; - self->iterator = 0; - } - - return (PyObject *)self; -} - -static void TransactionIterator_dealloc(TransactionIteratorObject* self) { - Py_XDECREF(self->transaction); - - Py_TYPE(self)->tp_free((PyObject *)self); -} - -static int TransactionIterator_init(TransactionIteratorObject* self, PyObject* args, PyObject* kwds) { - TransactionObject* transaction; - - if (!PyArg_ParseTuple(args, "O!", &TransactionType, &transaction)) - return -1; - - self->transaction = transaction; - Py_INCREF(self->transaction); - - return 0; -} - -static PyObject* TransactionIterator_next(TransactionIteratorObject* self) { - PakfireStep step = pakfire_transaction_get_step(self->transaction->transaction, self->iterator++); - if (step) - return new_step(self->transaction, step); - - return NULL; -} - -PyTypeObject TransactionIteratorType = { - PyVarObject_HEAD_INIT(NULL, 0) - tp_name: "_pakfire.TransactionIterator", - tp_basicsize: sizeof(TransactionIteratorObject), - tp_flags: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, - tp_new: TransactionIterator_new, - tp_dealloc: (destructor)TransactionIterator_dealloc, - tp_init: (initproc)TransactionIterator_init, - tp_doc: "TransactionIterator object", - tp_iternext: (iternextfunc)TransactionIterator_next, -}; diff --git a/src/_pakfire/transaction.h b/src/_pakfire/transaction.h index 314b8dd59..6233e8688 100644 --- a/src/_pakfire/transaction.h +++ b/src/_pakfire/transaction.h @@ -35,15 +35,6 @@ typedef struct { extern PyTypeObject TransactionType; -typedef struct { - PyObject_HEAD - TransactionObject* transaction; - int iterator; -} TransactionIteratorObject; - -extern PyTypeObject TransactionIteratorType; - PyObject* new_transaction(RequestObject* request, PakfireTransaction trans); -PyObject* new_transaction_iterator(TransactionObject* transaction); #endif /* PYTHON_PAKFIRE_TRANSACTION_H */