Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/rpm-software-management/createrepo_c.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleš Matěj <amatej@redhat.com>2022-03-17 16:24:41 +0300
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2022-03-29 07:56:13 +0300
commit7092ab2283477876bdcc5cd508848cc3976bca72 (patch)
tree0b02e3e8f0c8ed519ae9a612ed2babc7290307d9
parent2395ffb5a9ba787ffa6464e51621310dcfac91ce (diff)
Remove python bindings for xml_parse_main_metadata_together
They are obsoleted by cr.PackageIterator
-rw-r--r--src/python/createrepo_cmodule.c2
-rw-r--r--src/python/xml_parser-py.c83
-rw-r--r--src/python/xml_parser-py.h8
-rw-r--r--tests/python/tests/test_xml_parser.py228
4 files changed, 7 insertions, 314 deletions
diff --git a/src/python/createrepo_cmodule.c b/src/python/createrepo_cmodule.c
index fd6e7ef..ba6cad6 100644
--- a/src/python/createrepo_cmodule.c
+++ b/src/python/createrepo_cmodule.c
@@ -79,8 +79,6 @@ static struct PyMethodDef createrepo_c_methods[] = {
METH_VARARGS, xml_parse_repomd__doc__},
{"xml_parse_updateinfo", (PyCFunction)py_xml_parse_updateinfo,
METH_VARARGS, xml_parse_updateinfo__doc__},
- {"xml_parse_main_metadata_together",(PyCFunctionWithKeywords)py_xml_parse_main_metadata_together,
- METH_VARARGS | METH_KEYWORDS, xml_parse_main_metadata_together__doc__},
{"checksum_name_str", (PyCFunction)py_checksum_name_str,
METH_VARARGS, checksum_name_str__doc__},
{"checksum_type", (PyCFunction)py_checksum_type,
diff --git a/src/python/xml_parser-py.c b/src/python/xml_parser-py.c
index d9f05f9..1f9d981 100644
--- a/src/python/xml_parser-py.c
+++ b/src/python/xml_parser-py.c
@@ -708,89 +708,6 @@ py_xml_parse_updateinfo(G_GNUC_UNUSED PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-
-PyObject *
-py_xml_parse_main_metadata_together(G_GNUC_UNUSED PyObject *self, PyObject *args, PyObject *kwargs)
-{
- char *primary_filename;
- char *filelists_filename;
- char *other_filename;
- PyObject *py_newpkgcb, *py_pkgcb, *py_warningcb;
- CbData cbdata;
- GError *tmp_err = NULL;
- static char *kwlist[] = { "primary", "filelists", "other", "newpkgcb", "pkgcb",
- "warningcb", NULL };
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sssOOO:py_xml_parse_main_metadata_together", kwlist,
- &primary_filename, &filelists_filename, &other_filename, &py_newpkgcb,
- &py_pkgcb, &py_warningcb )) {
- return NULL;
- }
-
- if (!PyCallable_Check(py_newpkgcb) && py_newpkgcb != Py_None) {
- PyErr_SetString(PyExc_TypeError, "newpkgcb must be callable or None");
- return NULL;
- }
-
- if (!PyCallable_Check(py_pkgcb) && py_pkgcb != Py_None) {
- PyErr_SetString(PyExc_TypeError, "pkgcb must be callable or None");
- return NULL;
- }
-
- if (!PyCallable_Check(py_warningcb) && py_warningcb != Py_None) {
- PyErr_SetString(PyExc_TypeError, "warningcb must be callable or None");
- return NULL;
- }
-
- if (py_newpkgcb == Py_None && py_pkgcb == Py_None) {
- PyErr_SetString(PyExc_ValueError, "both pkgcb and newpkgcb cannot be None");
- return NULL;
- }
-
- Py_XINCREF(py_newpkgcb);
- Py_XINCREF(py_pkgcb);
- Py_XINCREF(py_warningcb);
-
- cr_XmlParserNewPkgCb ptr_c_newpkgcb = NULL;
- cr_XmlParserPkgCb ptr_c_pkgcb = NULL;
- cr_XmlParserWarningCb ptr_c_warningcb = NULL;
-
- if (py_newpkgcb != Py_None)
- ptr_c_newpkgcb = c_newpkgcb;
- if (py_pkgcb != Py_None)
- ptr_c_pkgcb = c_pkgcb;
- if (py_warningcb != Py_None)
- ptr_c_warningcb = c_warningcb;
-
- cbdata.py_newpkgcb = py_newpkgcb;
- cbdata.py_pkgcb = py_pkgcb;
- cbdata.py_warningcb = py_warningcb;
- cbdata.py_pkgs = PyDict_New();
-
- cr_xml_parse_main_metadata_together(primary_filename,
- filelists_filename,
- other_filename,
- ptr_c_newpkgcb,
- &cbdata,
- ptr_c_pkgcb,
- &cbdata,
- ptr_c_warningcb,
- &cbdata,
- &tmp_err);
-
- Py_XDECREF(py_newpkgcb);
- Py_XDECREF(py_pkgcb);
- Py_XDECREF(py_warningcb);
- Py_XDECREF(cbdata.py_pkgs);
-
- if (tmp_err) {
- nice_exception(&tmp_err, NULL);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
typedef struct {
PyObject_HEAD
cr_PkgIterator *pkg_iterator;
diff --git a/src/python/xml_parser-py.h b/src/python/xml_parser-py.h
index df5c620..444b32c 100644
--- a/src/python/xml_parser-py.h
+++ b/src/python/xml_parser-py.h
@@ -64,14 +64,6 @@ PyDoc_STRVAR(xml_parse_updateinfo__doc__,
PyObject *py_xml_parse_updateinfo(PyObject *self, PyObject *args);
-PyDoc_STRVAR(xml_parse_main_metadata_together__doc__,
-"xml_parse_main_metadata_together(primary_filename, filelists_filename, other_filename, newpkgcb, pkgcb, warningcb) -> None\n\n"
-"Parse primary.xml, filelists.xml and other.xml together at the same time."
-"- It can handle if packages are not in the same order in all 3 files but memory requirements grow."
-"- It is not guaranteed that newpkgcb is always followed by pkgcb for the given package, it is possible newpkgcb will be called several times for different packages and only after that pkgcbs will be called.");
-
-PyObject *py_xml_parse_main_metadata_together(PyObject *self, PyObject *args, PyObject *kwargs);
-
extern PyTypeObject PkgIterator_Type;
#define PkgIteratorObject_Check(o) PyObject_TypeCheck(o, &PkgIterator_Type)
diff --git a/tests/python/tests/test_xml_parser.py b/tests/python/tests/test_xml_parser.py
index c0cac1c..0240a9b 100644
--- a/tests/python/tests/test_xml_parser.py
+++ b/tests/python/tests/test_xml_parser.py
@@ -1147,227 +1147,6 @@ class TestCaseXmlParserRepomd(unittest.TestCase):
self.assertEqual(repomd.content_tags, [])
self.assertEqual(len(repomd.records), 3)
-class TestCaseXmlParserMainMetadataTogether(unittest.TestCase):
- def test_xml_parser_main_metadata_together_repo01(self):
- userdata = {
- "pkgs": [],
- "pkgcb_calls": 0,
- "warnings": []
- }
-
- def newpkgcb(pkgId, name, arch):
- pkg = cr.Package()
- userdata["pkgs"].append(pkg)
- return pkg
-
- def pkgcb(pkg):
- userdata["pkgcb_calls"] += 1
-
- def warningcb(warn_type, msg):
- userdata["warnings"].append((warn_type, msg))
-
- cr.xml_parse_main_metadata_together(primary=REPO_01_PRIXML, filelists=REPO_01_FILXML, other=REPO_01_OTHXML,
- newpkgcb=newpkgcb, pkgcb=pkgcb, warningcb=warningcb)
-
- self.assertEqual([pkg.name for pkg in userdata["pkgs"]], ['super_kernel'])
- self.assertEqual(userdata["pkgcb_calls"], 1)
- self.assertEqual(userdata["warnings"], [])
-
- pkg = userdata["pkgs"][0]
- self.assertEqual(pkg.pkgId, "152824bff2aa6d54f429d43e87a3ff3a0286505c6d93ec87692b5e3a9e3b97bf")
- self.assertEqual(pkg.name, "super_kernel")
- self.assertEqual(pkg.arch, "x86_64")
- self.assertEqual(pkg.version, "6.0.1")
- self.assertEqual(pkg.epoch, "0")
- self.assertEqual(pkg.release, "2")
- self.assertEqual(pkg.summary, "Test package")
- self.assertEqual(pkg.description, "This package has provides, requires, obsoletes, conflicts options.")
- self.assertEqual(pkg.url, "http://so_super_kernel.com/it_is_awesome/yep_it_really_is")
- self.assertEqual(pkg.time_file, 1334667003)
- self.assertEqual(pkg.time_build, 1334667003)
- self.assertEqual(pkg.rpm_license, "LGPLv2")
- self.assertEqual(pkg.rpm_vendor, None)
- self.assertEqual(pkg.rpm_group, "Applications/System")
- self.assertEqual(pkg.rpm_buildhost, "localhost.localdomain")
- self.assertEqual(pkg.rpm_sourcerpm, "super_kernel-6.0.1-2.src.rpm")
- self.assertEqual(pkg.rpm_header_start, 280)
- self.assertEqual(pkg.rpm_header_end, 2637)
- self.assertEqual(pkg.rpm_packager, None)
- self.assertEqual(pkg.size_package, 2845)
- self.assertEqual(pkg.size_installed, 0)
- self.assertEqual(pkg.size_archive, 404)
- self.assertEqual(pkg.location_href, "super_kernel-6.0.1-2.x86_64.rpm")
- self.assertEqual(pkg.location_base, None)
- self.assertEqual(pkg.checksum_type, "sha256")
- self.assertEqual(pkg.requires,
- [('bzip2', 'GE', '0', '1.0.0', None, True),
- ('expat', None, None, None, None, True),
- ('glib', 'GE', '0', '2.26.0', None, False),
- ('zlib', None, None, None, None, False)])
- self.assertEqual(pkg.provides,
- [('not_so_super_kernel', 'LT', '0', '5.8.0', None, False),
- ('super_kernel', 'EQ', '0', '6.0.0', None, False),
- ('super_kernel', 'EQ', '0', '6.0.1', '2', False),
- ('super_kernel(x86-64)', 'EQ', '0', '6.0.1', '2', False)])
- self.assertEqual(pkg.conflicts,
- [('kernel', None, None, None, None, False),
- ('super_kernel', 'EQ', '0', '5.0.0', None, False),
- ('super_kernel', 'LT', '0', '4.0.0', None, False)])
- self.assertEqual(pkg.obsoletes,
- [('kernel', None, None, None, None, False),
- ('super_kernel', 'EQ', '0', '5.9.0', None, False)])
- self.assertEqual(pkg.files,
- [(None, '/usr/bin/', 'super_kernel'),
- (None, '/usr/share/man/', 'super_kernel.8.gz')])
- self.assertEqual(pkg.changelogs,
- [('Tomas Mlcoch <tmlcoch@redhat.com> - 6.0.1-1',
- 1334664000,
- '- First release'),
- ('Tomas Mlcoch <tmlcoch@redhat.com> - 6.0.1-2',
- 1334664001,
- '- Second release')])
-
- def test_xml_parser_main_metadata_together_repo02(self):
-
- userdata = {
- "pkgs": [],
- "pkgcb_calls": 0,
- "warnings": []
- }
-
- def newpkgcb(pkgId, name, arch):
- pkg = cr.Package()
- userdata["pkgs"].append(pkg)
- return pkg
-
- def pkgcb(pkg):
- userdata["pkgcb_calls"] += 1
-
- def warningcb(warn_type, msg):
- userdata["warnings"].append((warn_type, msg))
-
- cr.xml_parse_main_metadata_together(REPO_02_PRIXML, REPO_02_FILXML, REPO_02_OTHXML, newpkgcb, pkgcb, warningcb)
-
- self.assertEqual([pkg.name for pkg in userdata["pkgs"]],
- ['fake_bash', 'super_kernel'])
- self.assertEqual(userdata["pkgcb_calls"], 2)
- self.assertEqual(userdata["warnings"], [])
-
- def test_xml_parser_main_metadata_together_repo02_only_pkgcb(self):
-
- pkgs = []
-
- def pkgcb(pkg):
- pkgs.append(pkg)
-
- cr.xml_parse_main_metadata_together(REPO_02_PRIXML, REPO_02_FILXML, REPO_02_OTHXML,
- None, pkgcb, None)
-
- self.assertEqual([pkg.name for pkg in pkgs],
- ['fake_bash', 'super_kernel'])
-
- def test_xml_parser_main_metadata_together_repo02_no_cbs(self):
- self.assertRaises(ValueError,
- cr.xml_parse_main_metadata_together,
- REPO_02_PRIXML, REPO_02_FILXML, REPO_02_OTHXML,
- None, None, None)
-
- def test_xml_parser_main_metadata_together_warnings(self):
- userdata = {
- "pkgs": [],
- "warnings": []
- }
-
- def newpkgcb(pkgId, name, arch):
- pkg = cr.Package()
- userdata["pkgs"].append(pkg)
- return pkg
-
- def warningcb(warn_type, msg):
- userdata["warnings"].append((warn_type, msg))
-
- cr.xml_parse_main_metadata_together(PRIMARY_MULTI_WARN_00_PATH,
- FILELISTS_MULTI_WARN_00_PATH,
- OTHER_MULTI_WARN_00_PATH,
- newpkgcb, None, warningcb)
-
- self.assertEqual([pkg.name for pkg in userdata["pkgs"]],
- ['fake_bash', 'super_kernel'])
- self.assertEqual(userdata["warnings"],
- [(0, 'Unknown element "fooelement"'),
- (1, 'Missing attribute "type" of a package element'),
- (0, 'Unknown element "foo"'),
- (3, 'Conversion of "foobar" to integer failed'),
- (0, 'Unknown element "bar"'),
- (1, 'Missing attribute "arch" of a package element'),
- (2, 'Unknown file type "xxx"'),
- (0, 'Unknown element "bar"'),
- (1, 'Missing attribute "name" of a package element'),
- (0, 'Unknown element "bar"'),
- (3, 'Conversion of "xxx" to integer failed')])
-
-
- def test_xml_parser_main_metadata_together_error(self):
- userdata = { "pkgs": [] }
-
- def newpkgcb(pkgId, name, arch):
- pkg = cr.Package()
- userdata["pkgs"].append(pkg)
- return pkg
-
- self.assertRaises(cr.CreaterepoCError, cr.xml_parse_main_metadata_together,
- PRIMARY_ERROR_00_PATH, REPO_02_FILXML,
- REPO_02_OTHXML, newpkgcb, None, None)
-
- # unlike parsing just primary, filelists or other separately when parsing together primary is parsed first fully
- # before newpkgcb is called so the error is detected before any user package is created
- self.assertEqual(len(userdata["pkgs"]), 0)
-
- # test when the error is filelists
- self.assertRaises(cr.CreaterepoCError, cr.xml_parse_main_metadata_together,
- REPO_02_PRIXML, FILELISTS_ERROR_00_PATH,
- REPO_02_OTHXML, newpkgcb, None, None)
-
- self.assertEqual(len(userdata["pkgs"]), 2)
-
- # test when the error is other
- userdata = { "pkgs": [] }
- self.assertRaises(cr.CreaterepoCError, cr.xml_parse_main_metadata_together,
- REPO_02_PRIXML, REPO_02_FILXML,
- OTHER_ERROR_00_PATH, newpkgcb, None, None)
-
- self.assertEqual(len(userdata["pkgs"]), 2)
-
- def test_xml_parser_main_metadata_together_newpkgcb_abort(self):
- def newpkgcb(pkgId, name, arch):
- raise Error("Foo error")
- self.assertRaises(cr.CreaterepoCError,
- cr.xml_parse_main_metadata_together,
- REPO_02_PRIXML, REPO_02_FILXML, REPO_02_OTHXML,
- newpkgcb, None, None)
-
- def test_xml_parser_main_metadata_together_pkgcb_abort(self):
- def newpkgcb(pkgId, name, arch):
- return cr.Package()
- def pkgcb(pkg):
- raise Error("Foo error")
- self.assertRaises(cr.CreaterepoCError,
- cr.xml_parse_main_metadata_together,
- REPO_02_PRIXML, REPO_02_FILXML, REPO_02_OTHXML,
- newpkgcb, pkgcb, None)
-
- def test_xml_parser_main_metadata_together_warningcb_abort(self):
- def newpkgcb(pkgId, name, arch):
- return cr.Package()
- def warningcb(type, msg):
- raise Error("Foo error")
- self.assertRaises(cr.CreaterepoCError,
- cr.xml_parse_main_metadata_together,
- PRIMARY_MULTI_WARN_00_PATH,
- FILELISTS_MULTI_WARN_00_PATH,
- OTHER_MULTI_WARN_00_PATH,
- newpkgcb, None, warningcb)
-
class TestCaseXmlParserPkgIterator(unittest.TestCase):
def test_xml_parser_pkg_iterator_repo01(self):
warnings = []
@@ -1513,6 +1292,13 @@ class TestCaseXmlParserPkgIterator(unittest.TestCase):
with self.assertRaises(cr.CreaterepoCError) as ctx:
packages = list(package_iterator)
+ # test when the error is only in other.xml
+ package_iterator2 = cr.PackageIterator(
+ primary_path=REPO_02_PRIXML, filelists_path=REPO_02_FILXML, other_path=OTHER_ERROR_00_PATH,
+ )
+
+ with self.assertRaises(cr.CreaterepoCError) as ctx:
+ packages = list(package_iterator2)
def test_xml_parser_pkg_iterator_newpkgcb_abort(self):
def newpkgcb(pkgId, name, arch):