static int metadatalocation_init(_MetadataLocationObject *self, PyObject *args, G_GNUC_UNUSED PyObject *kwds) { char *repopath; PyObject *py_ignore_db = NULL; GError *tmp_err = NULL; if (!PyArg_ParseTuple(args, "sO|:metadatalocation_init", &repopath, &py_ignore_db)) return -1; /* Free all previous resources when reinitialization */ if (self->ml) { cr_metadatalocation_free(self->ml); } /* Init */ self->ml = cr_locate_metadata(repopath, PyObject_IsTrue(py_ignore_db), &tmp_err); if (tmp_err) { nice_exception(&tmp_err, NULL); return -1; } return 0; }
static PyObject * compress_and_fill(_RepomdRecordObject *self, PyObject *args) { int checksum_type, compression_type; PyObject *compressed_repomdrecord; GError *err = NULL; if (!PyArg_ParseTuple(args, "O!ii:compress_and_fill", &RepomdRecord_Type, &compressed_repomdrecord, &checksum_type, &compression_type)) return NULL; if (check_RepomdRecordStatus(self)) return NULL; cr_repomd_record_compress_and_fill(self->record, RepomdRecord_FromPyObject(compressed_repomdrecord), checksum_type, compression_type, &err); if (err) { nice_exception(&err, NULL); return NULL; } Py_RETURN_NONE; }
static int sqlite_init(_SqliteObject *self, PyObject *args, G_GNUC_UNUSED PyObject *kwds) { char *path; int db_type; GError *err = NULL; PyObject *ret; if (!PyArg_ParseTuple(args, "si|:sqlite_init", &path, &db_type)) return -1; /* Check arguments */ if (db_type < CR_DB_PRIMARY || db_type >= CR_DB_SENTINEL) { PyErr_SetString(PyExc_ValueError, "Unknown db type"); return -1; } /* Free all previous resources when reinitialization */ ret = close_db(self, NULL); Py_XDECREF(ret); if (ret == NULL) { // Error encountered! return -1; } /* Init */ self->db = cr_db_open(path, db_type, &err); if (err) { nice_exception(&err, NULL); return -1; } return 0; }
PyObject * py_package_from_rpm(G_GNUC_UNUSED PyObject *self, PyObject *args) { PyObject *ret; cr_Package *pkg; int checksum_type, changelog_limit; char *filename, *location_href, *location_base; GError *tmp_err = NULL; cr_HeaderReadingFlags flags = CR_HDRR_NONE; // TODO - support for flags if (!PyArg_ParseTuple(args, "sizzi:py_package_from_rpm", &filename, &checksum_type, &location_href, &location_base, &changelog_limit)) { return NULL; } pkg = cr_package_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit, NULL, flags, &tmp_err); if (tmp_err) { nice_exception(&tmp_err, "Cannot load %s: ", filename); return NULL; } ret = Object_FromPackage(pkg, 1); return ret; }
PyObject * py_package_from_rpm(PyObject *self, PyObject *args) { CR_UNUSED(self); PyObject *ret; cr_Package *pkg; int checksum_type, changelog_limit; char *filename, *location_href, *location_base; GError *tmp_err = NULL; if (!PyArg_ParseTuple(args, "sizzi:py_package_from_rpm", &filename, &checksum_type, &location_href, &location_base, &changelog_limit)) { return NULL; } pkg = cr_package_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit, NULL, &tmp_err); if (tmp_err) { nice_exception(&tmp_err, "Cannot load %s: ", filename); return NULL; } ret = Object_FromPackage(pkg, 1); return ret; }
PyObject * py_xml_dump(G_GNUC_UNUSED PyObject *self, PyObject *args) { PyObject *py_pkg, *tuple; struct cr_XmlStruct xml_res; GError *err = NULL; if (!PyArg_ParseTuple(args, "O!:py_xml_dump", &Package_Type, &py_pkg)) return NULL; xml_res = cr_xml_dump(Package_FromPyObject(py_pkg), &err); if (err) { nice_exception(&err, NULL); return NULL; } if ((tuple = PyTuple_New(3)) == NULL) { free(xml_res.primary); free(xml_res.filelists); free(xml_res.other); return NULL; } PyTuple_SetItem(tuple, 0, PyUnicodeOrNone_FromString(xml_res.primary)); PyTuple_SetItem(tuple, 1, PyUnicodeOrNone_FromString(xml_res.filelists)); PyTuple_SetItem(tuple, 2, PyUnicodeOrNone_FromString(xml_res.other)); free(xml_res.primary); free(xml_res.filelists); free(xml_res.other); return tuple; }
static PyObject * rename_file(_RepomdRecordObject *self, G_GNUC_UNUSED void *nothing) { GError *err = NULL; cr_repomd_record_rename_file(self->record, &err); if (err) { nice_exception(&err, NULL); return NULL; } Py_RETURN_NONE; }
static PyObject * close_db(_SqliteObject *self, G_GNUC_UNUSED void *nothing) { GError *err = NULL; if (self->db) { cr_db_close(self->db, &err); self->db = NULL; if (err) { nice_exception(&err, NULL); return NULL; } } Py_RETURN_NONE; }
static PyObject * dbinfo_update(_SqliteObject *self, PyObject *args) { char *checksum; GError *err = NULL; if (!PyArg_ParseTuple(args, "s:dbinfo_update", &checksum)) return NULL; if (check_SqliteStatus(self)) return NULL; cr_db_dbinfo_update(self->db, checksum, &err); if (err) { nice_exception(&err, NULL); return NULL; } Py_RETURN_NONE; }
static PyObject * add_pkg(_SqliteObject *self, PyObject *args) { PyObject *py_pkg; GError *err = NULL; if (!PyArg_ParseTuple(args, "O!:add_pkg", &Package_Type, &py_pkg)) return NULL; if (check_SqliteStatus(self)) return NULL; cr_db_add_pkg(self->db, Package_FromPyObject(py_pkg), &err); if (err) { nice_exception(&err, NULL); return NULL; } Py_RETURN_NONE; }
static PyObject * fill(_RepomdRecordObject *self, PyObject *args) { int checksum_type; GError *err = NULL; if (!PyArg_ParseTuple(args, "i:fill", &checksum_type)) return NULL; if (check_RepomdRecordStatus(self)) return NULL; cr_repomd_record_fill(self->record, checksum_type, &err); if (err) { nice_exception(&err, NULL); return NULL; } Py_RETURN_NONE; }
PyObject * py_xml_dump_other(G_GNUC_UNUSED PyObject *self, PyObject *args) { PyObject *py_pkg, *py_str; char *xml; GError *err = NULL; if (!PyArg_ParseTuple(args, "O!:py_xml_dump_other", &Package_Type, &py_pkg)) return NULL; xml = cr_xml_dump_other(Package_FromPyObject(py_pkg), &err); if (err) { nice_exception(&err, NULL); return NULL; } py_str = PyUnicodeOrNone_FromString(xml); free(xml); return py_str; }
PyObject * py_xml_from_rpm(PyObject *self, PyObject *args) { CR_UNUSED(self); PyObject *tuple; int checksum_type, changelog_limit; char *filename, *location_href, *location_base; struct cr_XmlStruct xml_res; GError *tmp_err = NULL; if (!PyArg_ParseTuple(args, "sizzi:py_xml_from_rpm", &filename, &checksum_type, &location_href, &location_base, &changelog_limit)) { return NULL; } xml_res = cr_xml_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit, NULL, &tmp_err); if (tmp_err) { nice_exception(&tmp_err, "Cannot load %s: ", filename); return NULL; } if ((tuple = PyTuple_New(3)) == NULL) goto py_xml_from_rpm_end; // Free xml_res and return NULL PyTuple_SetItem(tuple, 0, PyStringOrNone_FromString(xml_res.primary)); PyTuple_SetItem(tuple, 1, PyStringOrNone_FromString(xml_res.filelists)); PyTuple_SetItem(tuple, 2, PyStringOrNone_FromString(xml_res.other)); py_xml_from_rpm_end: free(xml_res.primary); free(xml_res.filelists); free(xml_res.other); return tuple; }
PyObject * py_xml_dump_updaterecord(G_GNUC_UNUSED PyObject *self, PyObject *args) { PyObject *py_rec, *py_str; char *xml = NULL; GError *err = NULL; if (!PyArg_ParseTuple(args, "O!:py_xml_dump_updaterecord", &UpdateRecord_Type, &py_rec)) return NULL; xml = cr_xml_dump_updaterecord(UpdateRecord_FromPyObject(py_rec), &err); if (err) { nice_exception(&err, NULL); free(xml); return NULL; } py_str = PyUnicodeOrNone_FromString(xml); free(xml); return py_str; }