From 5926858b582c3326d10550e4d787aa363d09bff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 2 Aug 2018 14:24:46 +0200 Subject: [PATCH] util: Remove escaping spaces from volume ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was not configurable for users, and the default was always used, which meant no escaping. Might as well just remove the dead code. Signed-off-by: Lubomír Sedlář --- pungi/phases/buildinstall.py | 2 +- pungi/util.py | 5 +---- tests/test_buildinstall.py | 24 ++++++++++++------------ tests/test_util.py | 6 +++--- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index c77a07c1..088863ec 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -220,7 +220,7 @@ class BuildinstallPhase(PhaseBase): os_tree = self.compose.paths.compose.os_tree(arch, variant) # TODO: label is not used label = "" - volid = get_volid(self.compose, arch, variant, escape_spaces=False, disc_type=disc_type) + volid = get_volid(self.compose, arch, variant, disc_type=disc_type) can_fail = self.compose.can_fail(variant, arch, 'buildinstall') with failable(self.compose, can_fail, variant, arch, 'buildinstall'): tweak_buildinstall(self.compose, buildinstall_dir, os_tree, arch, variant.uid, label, volid, kickstart_file) diff --git a/pungi/util.py b/pungi/util.py index 84c4d326..65f3fe61 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -334,7 +334,7 @@ def _apply_substitutions(compose, volid): return volid -def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False, +def get_volid(compose, arch, variant=None, disc_type=False, formats=None, **kwargs): """Get ISO volume ID for arch and variant""" if variant and variant.type == "addon": @@ -397,9 +397,6 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False, # dashes. volid = re.sub(r"\W", "-", volid, flags=re.I) - if volid and escape_spaces: - volid = volid.replace(" ", r"\x20") - return volid diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index ff333194..38937029 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -550,7 +550,7 @@ class TestCopyFiles(PungiTestCase): }) get_volid.side_effect = ( - lambda compose, arch, variant, escape_spaces, disc_type: "%s.%s" % (variant.uid, arch) + lambda compose, arch, variant, disc_type: "%s.%s" % (variant.uid, arch) ) get_kickstart_file.return_value = 'kickstart' @@ -560,9 +560,9 @@ class TestCopyFiles(PungiTestCase): self.assertItemsEqual( get_volid.mock_calls, - [mock.call(compose, 'x86_64', compose.variants['Server'], escape_spaces=False, disc_type='dvd'), - mock.call(compose, 'amd64', compose.variants['Client'], escape_spaces=False, disc_type='dvd'), - mock.call(compose, 'amd64', compose.variants['Server'], escape_spaces=False, disc_type='dvd')]) + [mock.call(compose, 'x86_64', compose.variants['Server'], disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Client'], disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Server'], disc_type='dvd')]) self.assertItemsEqual( tweak_buildinstall.mock_calls, [mock.call(compose, @@ -612,7 +612,7 @@ class TestCopyFiles(PungiTestCase): }) get_volid.side_effect = ( - lambda compose, arch, variant, escape_spaces, disc_type: "%s.%s" % (variant.uid, arch) + lambda compose, arch, variant, disc_type: "%s.%s" % (variant.uid, arch) ) get_kickstart_file.return_value = 'kickstart' @@ -622,9 +622,9 @@ class TestCopyFiles(PungiTestCase): self.assertItemsEqual( get_volid.mock_calls, - [mock.call(compose, 'x86_64', compose.variants['Server'], escape_spaces=False, disc_type='dvd'), - mock.call(compose, 'amd64', compose.variants['Client'], escape_spaces=False, disc_type='dvd'), - mock.call(compose, 'amd64', compose.variants['Server'], escape_spaces=False, disc_type='dvd')]) + [mock.call(compose, 'x86_64', compose.variants['Server'], disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Client'], disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Server'], disc_type='dvd')]) self.assertItemsEqual( tweak_buildinstall.mock_calls, [mock.call(compose, @@ -677,7 +677,7 @@ class TestCopyFiles(PungiTestCase): }) get_volid.side_effect = ( - lambda compose, arch, variant, escape_spaces, disc_type: "%s.%s" % (variant.uid, arch) + lambda compose, arch, variant, disc_type: "%s.%s" % (variant.uid, arch) ) get_kickstart_file.return_value = 'kickstart' tweak_buildinstall.side_effect = boom @@ -688,9 +688,9 @@ class TestCopyFiles(PungiTestCase): self.assertItemsEqual( get_volid.mock_calls, - [mock.call(compose, 'x86_64', compose.variants['Server'], escape_spaces=False, disc_type='dvd'), - mock.call(compose, 'amd64', compose.variants['Client'], escape_spaces=False, disc_type='dvd'), - mock.call(compose, 'amd64', compose.variants['Server'], escape_spaces=False, disc_type='dvd')]) + [mock.call(compose, 'x86_64', compose.variants['Server'], disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Client'], disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Server'], disc_type='dvd')]) self.assertItemsEqual( tweak_buildinstall.mock_calls, [mock.call(compose, diff --git a/tests/test_util.py b/tests/test_util.py index 6cd66c4b..9e247cde 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -198,7 +198,7 @@ class TestVolumeIdGenerator(unittest.TestCase): c = compose.Compose(conf, self.tmp_dir) - volid = util.get_volid(c, 'x86_64', variant, escape_spaces=False, disc_type=False) + volid = util.get_volid(c, 'x86_64', variant, disc_type=False) self.assertEqual(volid, expected) @@ -234,7 +234,7 @@ class TestVolumeIdGenerator(unittest.TestCase): c = compose.Compose(conf, self.tmp_dir) - volid = util.get_volid(c, 'x86_64', variant, escape_spaces=False, disc_type=False) + volid = util.get_volid(c, 'x86_64', variant, disc_type=False) self.assertEqual(volid, expected) @@ -255,7 +255,7 @@ class TestVolumeIdGenerator(unittest.TestCase): c = compose.Compose(conf, self.tmp_dir) with self.assertRaises(ValueError) as ctx: - util.get_volid(c, 'x86_64', variant, escape_spaces=False, disc_type=False) + util.get_volid(c, 'x86_64', variant, disc_type=False) self.assertIn('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', str(ctx.exception)) self.assertIn('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', str(ctx.exception))