Ensure recorder loaded first to capture all

This commit is contained in:
Paulus Schoutsen 2015-01-31 20:05:18 -08:00
parent 10bbc3d6e1
commit 3c95d80d3e
2 changed files with 16 additions and 1 deletions

View file

@ -147,6 +147,7 @@ def load_order_components(components):
Takes in a list of components we want to load: Takes in a list of components we want to load:
- filters out components we cannot load - filters out components we cannot load
- filters out components that have invalid/circular dependencies - filters out components that have invalid/circular dependencies
- Will make sure the recorder component is loaded first
- Will ensure that all components that do not directly depend on - Will ensure that all components that do not directly depend on
the group component will be loaded before the group component. the group component will be loaded before the group component.
- returns an OrderedSet load order. - returns an OrderedSet load order.
@ -154,6 +155,7 @@ def load_order_components(components):
_check_prepared() _check_prepared()
group = get_component('group') group = get_component('group')
recorder = get_component('recorder')
load_order = OrderedSet() load_order = OrderedSet()
@ -171,6 +173,10 @@ def load_order_components(components):
group and group.DOMAIN in order): group and group.DOMAIN in order):
load_order.update(comp_load_order) load_order.update(comp_load_order)
# Push recorder to first place in load order
if recorder.DOMAIN in load_order:
load_order.promote(recorder.DOMAIN)
return load_order return load_order

View file

@ -216,12 +216,21 @@ class OrderedSet(collections.MutableSet):
return key in self.map return key in self.map
def add(self, key): def add(self, key):
""" Add an element to the set. """ """ Add an element to the end of the set. """
if key not in self.map: if key not in self.map:
end = self.end end = self.end
curr = end[1] curr = end[1]
curr[2] = end[1] = self.map[key] = [key, curr, end] curr[2] = end[1] = self.map[key] = [key, curr, end]
def promote(self, key):
""" Promote element to beginning of the set, add if not there. """
if key in self.map:
self.discard(key)
begin = self.end[2]
curr = begin[1]
curr[2] = begin[1] = self.map[key] = [key, curr, begin]
def discard(self, key): def discard(self, key):
""" Discard an element from the set. """ """ Discard an element from the set. """
if key in self.map: if key in self.map: