1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Merge pull request #966 from octodns/yaml-filenames-refactor

Refactor YamlProvider to add get_filenames
This commit is contained in:
Ross McFarland
2022-12-09 08:51:12 -08:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -12,6 +12,8 @@
#### Stuff #### Stuff
* Added simple IgnoreRootNsFilter * Added simple IgnoreRootNsFilter
* Minor refactor on YamlProvider to add get_filenames making it a bit easier to
create specialized providers inheriting from it
## v0.9.21 - 2022-10-16 - Last of the oughts ## v0.9.21 - 2022-10-16 - Last of the oughts

View File

@@ -183,6 +183,12 @@ class YamlProvider(BaseProvider):
'_populate_from_file: successfully loaded "%s"', filename '_populate_from_file: successfully loaded "%s"', filename
) )
def get_filenames(self, zone):
return (
join(self.directory, f'{zone.decoded_name}yaml'),
join(self.directory, f'{zone.name}yaml'),
)
def populate(self, zone, target=False, lenient=False): def populate(self, zone, target=False, lenient=False):
self.log.debug( self.log.debug(
'populate: name=%s, target=%s, lenient=%s', 'populate: name=%s, target=%s, lenient=%s',
@@ -197,8 +203,7 @@ class YamlProvider(BaseProvider):
return False return False
before = len(zone.records) before = len(zone.records)
utf8_filename = join(self.directory, f'{zone.decoded_name}yaml') utf8_filename, idna_filename = self.get_filenames(zone)
idna_filename = join(self.directory, f'{zone.name}yaml')
# we prefer utf8 # we prefer utf8
if isfile(utf8_filename): if isfile(utf8_filename):