From 16ac2250134ac14b9922563fe7c6bf5a75e625f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 17 Jul 2018 13:11:13 +0200 Subject: [PATCH] comps: Add get_langpacks function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also simplifies the test data by removing a lot of the langpacks. Signed-off-by: Lubomír Sedlář --- pungi/wrappers/comps.py | 6 ++++++ tests/fixtures/comps-env.xml | 19 ------------------- tests/fixtures/comps-formatted.xml | 19 ------------------- tests/fixtures/comps-group.xml | 19 ------------------- tests/fixtures/comps.xml | 19 ------------------- tests/test_comps_wrapper.py | 11 +++++++++++ 6 files changed, 17 insertions(+), 76 deletions(-) diff --git a/pungi/wrappers/comps.py b/pungi/wrappers/comps.py index 3160a509..2ace7b21 100644 --- a/pungi/wrappers/comps.py +++ b/pungi/wrappers/comps.py @@ -234,6 +234,12 @@ class CompsWrapper(object): return [pkg.name for pkg in grp.packages] raise KeyError('No such group %r' % group) + def get_langpacks(self): + langpacks = {} + for pack in self.comps.langpacks: + langpacks[pack] = self.comps.langpacks[pack] + return langpacks + def validate(self): """Check that no package name contains whitespace, and raise a RuntimeError if there is a problem. diff --git a/tests/fixtures/comps-env.xml b/tests/fixtures/comps-env.xml index 169bd066..ec330df1 100644 --- a/tests/fixtures/comps-env.xml +++ b/tests/fixtures/comps-env.xml @@ -99,27 +99,8 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/fixtures/comps-formatted.xml b/tests/fixtures/comps-formatted.xml index cbce574d..58c60483 100644 --- a/tests/fixtures/comps-formatted.xml +++ b/tests/fixtures/comps-formatted.xml @@ -113,27 +113,8 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/fixtures/comps-group.xml b/tests/fixtures/comps-group.xml index 78b5be26..f2985afa 100644 --- a/tests/fixtures/comps-group.xml +++ b/tests/fixtures/comps-group.xml @@ -79,27 +79,8 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/fixtures/comps.xml b/tests/fixtures/comps.xml index a303cf5c..ec135e97 100644 --- a/tests/fixtures/comps.xml +++ b/tests/fixtures/comps.xml @@ -126,28 +126,9 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/test_comps_wrapper.py b/tests/test_comps_wrapper.py index 46cc3b9f..f984fcd5 100644 --- a/tests/test_comps_wrapper.py +++ b/tests/test_comps_wrapper.py @@ -48,6 +48,17 @@ class CompsWrapperTest(unittest.TestCase): sorted(comps.get_packages('text-internet')), sorted(['dummy-elinks', 'dummy-tftp'])) + def test_get_langpacks(self): + comps = CompsWrapper(COMPS_FILE) + self.assertEqual( + comps.get_langpacks(), + { + "aspell": "aspell-%s", + "firefox": "firefox-langpack-%s", + "kdelibs": "kde-l10n-%s", + } + ) + def test_get_packages_for_non_existing_group(self): comps = CompsWrapper(COMPS_FILE) with self.assertRaises(KeyError):