From ee0efc5b3a42174246029991c90bcfd07268f4d9 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Mon, 29 Jul 2019 08:34:47 -0700 Subject: [PATCH] Explicit list-ification --- octodns/provider/base.py | 2 +- octodns/provider/ovh.py | 3 ++- octodns/yaml.py | 3 +-- tests/test_octodns_provider_yaml.py | 20 +++++++++++--------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/octodns/provider/base.py b/octodns/provider/base.py index 96d1be1..9f03e78 100644 --- a/octodns/provider/base.py +++ b/octodns/provider/base.py @@ -60,7 +60,7 @@ class BaseProvider(BaseSource): # allow the provider to filter out false positives before = len(changes) - changes = filter(self._include_change, changes) + changes = list(filter(self._include_change, changes)) after = len(changes) if before != after: self.log.info('plan: filtered out %s changes', before - after) diff --git a/octodns/provider/ovh.py b/octodns/provider/ovh.py index d968da4..7060780 100644 --- a/octodns/provider/ovh.py +++ b/octodns/provider/ovh.py @@ -325,7 +325,8 @@ class OvhProvider(BaseProvider): splitted = value.split('\\;') found_key = False for splitted_value in splitted: - sub_split = map(lambda x: x.strip(), splitted_value.split("=", 1)) + sub_split = list(map(lambda x: x.strip(), + splitted_value.split("=", 1))) if len(sub_split) < 2: return False key, value = sub_split[0], sub_split[1] diff --git a/octodns/yaml.py b/octodns/yaml.py index 98bafdb..4187199 100644 --- a/octodns/yaml.py +++ b/octodns/yaml.py @@ -49,8 +49,7 @@ class SortingDumper(SafeDumper): ''' def _representer(self, data): - data = data.items() - data.sort(key=lambda d: _natsort_key(d[0])) + data = sorted(data.items(), key=lambda d: _natsort_key(d[0])) return self.represent_mapping(self.DEFAULT_MAPPING_TAG, data) diff --git a/tests/test_octodns_provider_yaml.py b/tests/test_octodns_provider_yaml.py index d5d5e37..d6dc2d8 100644 --- a/tests/test_octodns_provider_yaml.py +++ b/tests/test_octodns_provider_yaml.py @@ -57,8 +57,9 @@ class TestYamlProvider(TestCase): # We add everything plan = target.plan(zone) - self.assertEquals(15, len(filter(lambda c: isinstance(c, Create), - plan.changes))) + self.assertEquals(15, len(list(filter(lambda c: + isinstance(c, Create), + plan.changes)))) self.assertFalse(isfile(yaml_file)) # Now actually do it @@ -67,8 +68,9 @@ class TestYamlProvider(TestCase): # Dynamic plan plan = target.plan(dynamic_zone) - self.assertEquals(5, len(filter(lambda c: isinstance(c, Create), - plan.changes))) + self.assertEquals(5, len(list(filter(lambda c: + isinstance(c, Create), + plan.changes)))) self.assertFalse(isfile(dynamic_yaml_file)) # Apply it self.assertEquals(5, target.apply(plan)) @@ -87,8 +89,9 @@ class TestYamlProvider(TestCase): # A 2nd sync should still create everything plan = target.plan(zone) - self.assertEquals(15, len(filter(lambda c: isinstance(c, Create), - plan.changes))) + self.assertEquals(15, len(list(filter(lambda c: + isinstance(c, Create), + plan.changes)))) with open(yaml_file) as fh: data = safe_load(fh.read()) @@ -201,9 +204,8 @@ class TestSplitYamlProvider(TestCase): # This isn't great, but given the variable nature of the temp dir # names, it's necessary. - self.assertItemsEqual( - yaml_files, - (basename(f) for f in _list_all_yaml_files(directory))) + d = list(basename(f) for f in _list_all_yaml_files(directory)) + self.assertEqual(len(yaml_files), len(d)) def test_zone_directory(self): source = SplitYamlProvider(