Py_RETURN_NONE;
}
+static PyObject* Progressbar_enter(ProgressbarObject* self) {
+ int r = pakfire_progressbar_start(self->progressbar, 0);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ // Return self
+ Py_INCREF(self);
+ return (PyObject*)self;
+}
+
+static PyObject* Progressbar_exit(ProgressbarObject* self, PyObject* args) {
+ int r = pakfire_progressbar_finish(self->progressbar);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef Progressbar_methods[] = {
{
"start",
METH_NOARGS,
NULL,
},
+ {
+ "__enter__",
+ (PyCFunction)Progressbar_enter,
+ METH_NOARGS,
+ NULL,
+ },
+ {
+ "__exit__",
+ (PyCFunction)Progressbar_exit,
+ METH_VARARGS,
+ NULL,
+ },
{ NULL },
};