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

Use collections.deque for pop'ing

This commit is contained in:
Ross McFarland
2022-08-11 08:53:19 -07:00
parent 611431b042
commit 810cc7faff

View File

@@ -9,6 +9,7 @@ from __future__ import (
unicode_literals, unicode_literals,
) )
from collections import deque
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from importlib import import_module from importlib import import_module
from os import environ from os import environ
@@ -234,15 +235,16 @@ class Manager(object):
if self._zone_tree is None: if self._zone_tree is None:
zone_tree = {} zone_tree = {}
# Get a list of all of our zone names # Get a list of all of our zone names. Sort them from shortest to
zones = list(self.config['zones'].keys()) # longest so that parents will always come before their subzones
# Sort them from shortest to longest so that parents will always zones = sorted(
# come before their subzones self.config['zones'].keys(), key=lambda z: len(z), reverse=True
zones.sort(key=lambda z: len(z)) )
zones = deque(zones)
# Until we're done processing zones # Until we're done processing zones
while zones: while zones:
# Grab the one we'lre going to work on now # Grab the one we'lre going to work on now
zone = zones.pop(0) zone = zones.pop()
trimmer = len(zone) + 1 trimmer = len(zone) + 1
subs = set() subs = set()
# look at all the zone names that come after it # look at all the zone names that come after it