]> git.ipfire.org Git - pakfire.git/commitdiff
python: Drop step
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Apr 2021 16:46:56 +0000 (16:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Apr 2021 16:46:56 +0000 (16:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/_pakfire/_pakfiremodule.c
src/_pakfire/step.c [deleted file]
src/_pakfire/step.h [deleted file]
src/_pakfire/transaction.c
src/_pakfire/transaction.h

index 966faec0b26e2a08178409bc63bc381482eebd13..47661d60be5aaae3b948db001aeebee9f825b086 100644 (file)
@@ -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 \
index 937c843c78d59ec43bebe0567cf229fb93f24c33..445f047ac7fd779273708c44267efb7482ee9b68 100644 (file)
@@ -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 (file)
index 80d795a..0000000
+++ /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 <http://www.gnu.org/licenses/>.       #
-#                                                                             #
-#############################################################################*/
-
-#include <Python.h>
-
-#include <pakfire/package.h>
-#include <pakfire/step.h>
-#include <pakfire/transaction.h>
-#include <pakfire/util.h>
-
-#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 (file)
index f218318..0000000
+++ /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 <http://www.gnu.org/licenses/>.       #
-#                                                                             #
-#############################################################################*/
-
-#ifndef PYTHON_PAKFIRE_STEP_H
-#define PYTHON_PAKFIRE_STEP_H
-
-#include <Python.h>
-
-#include <pakfire/types.h>
-
-#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 */
index a115e14aa183435b680d4717203b0978562f1086..f5dc8b8cfde9ef51505131c393c4714b3c893cd3 100644 (file)
@@ -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,
-};
index 314b8dd593350d1b0e27d6adfc08d90b6e244933..6233e8688addc758516afca1cfb90455c4400f5a 100644 (file)
@@ -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 */