mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Don't use classmethod for listing YAML files
Signed-off-by: Christian Funkhouser <cfunkhouser@heroku.com>
This commit is contained in:
@@ -117,6 +117,15 @@ class YamlProvider(BaseProvider):
|
||||
safe_dump(dict(data), fh)
|
||||
|
||||
|
||||
def _list_all_yaml_files(directory):
|
||||
yaml_files = set()
|
||||
for f in listdir(directory):
|
||||
filename = join(directory, '{}'.format(f))
|
||||
if f.endswith('.yaml') and isfile(filename):
|
||||
yaml_files.add(filename)
|
||||
return list(yaml_files)
|
||||
|
||||
|
||||
class SplitYamlProvider(YamlProvider):
|
||||
'''
|
||||
Core provider for records configured in multiple YAML files on disk.
|
||||
@@ -144,15 +153,6 @@ class SplitYamlProvider(YamlProvider):
|
||||
# instead of a file matching the record name.
|
||||
CATCHALL_RECORD_NAMES = ('*', '')
|
||||
|
||||
@classmethod
|
||||
def list_all_yaml_files(_, directory):
|
||||
yaml_files = set()
|
||||
for f in listdir(directory):
|
||||
filename = join(directory, '{}'.format(f))
|
||||
if f.endswith('.yaml') and isfile(filename):
|
||||
yaml_files.add(filename)
|
||||
return list(yaml_files)
|
||||
|
||||
def __init__(self, id, directory, *args, **kwargs):
|
||||
super(SplitYamlProvider, self).__init__(id, directory, *args, **kwargs)
|
||||
|
||||
@@ -169,7 +169,7 @@ class SplitYamlProvider(YamlProvider):
|
||||
return False
|
||||
|
||||
before = len(zone.records)
|
||||
yaml_filenames = self.list_all_yaml_files(self._zone_directory(zone))
|
||||
yaml_filenames = _list_all_yaml_files(self._zone_directory(zone))
|
||||
self.log.info('populate: found %s YAML files', len(yaml_filenames))
|
||||
for yaml_filename in yaml_filenames:
|
||||
self._populate_from_file(yaml_filename, zone, lenient)
|
||||
|
||||
@@ -13,7 +13,8 @@ from yaml.constructor import ConstructorError
|
||||
|
||||
from octodns.record import Create
|
||||
from octodns.provider.base import Plan
|
||||
from octodns.provider.yaml import SplitYamlProvider, YamlProvider
|
||||
from octodns.provider.yaml import _list_all_yaml_files, \
|
||||
SplitYamlProvider, YamlProvider
|
||||
from octodns.zone import SubzoneRecordException, Zone
|
||||
|
||||
from helpers import TemporaryDirectory
|
||||
@@ -200,9 +201,9 @@ class TestSplitYamlProvider(TestCase):
|
||||
|
||||
# This isn't great, but given the variable nature of the temp dir
|
||||
# names, it's necessary.
|
||||
got = (basename(f)
|
||||
for f in SplitYamlProvider.list_all_yaml_files(directory))
|
||||
self.assertItemsEqual(yaml_files, got)
|
||||
self.assertItemsEqual(
|
||||
yaml_files,
|
||||
(basename(f) for f in _list_all_yaml_files(directory)))
|
||||
|
||||
def test_zone_directory(self):
|
||||
source = SplitYamlProvider(
|
||||
|
||||
Reference in New Issue
Block a user