from .toposort import topological_sort
from .publish import publish
from .reify import reify


class TweenRegistry(object):
    def __init__(self):
        self._tween_factories = {}

    def register_tween_factory(self, tween_factory, over, under):
        self._tween_factories[tween_factory] = over, under

    def clear(self):
        self._tween_factories = {}

    def sorted_tween_factories(self):
        tween_factory_depends = {}
        for tween_factory, (over, under) in self._tween_factories.items():
            depends = []
            if under is not None:
                depends.append(under)
            tween_factory_depends[tween_factory] = depends
        for tween_factory, (over, under) in self._tween_factories.items():
            if over is not None:
                depends = tween_factory_depends.get(over)
                if depends is None:
                    tween_factory_depends[over] = depends = []
                depends.append(tween_factory)
        return topological_sort(
            self._tween_factories.keys(),
            lambda tween_factory: tween_factory_depends.get(tween_factory, []))

    @reify
    def publish(self):
        result = publish
        for tween_factory in reversed(self.sorted_tween_factories()):
            result = tween_factory(self, result)
        return result

@@ -823,116 +823,13 @@
 ends
-.get(over)%0A                if depends is None:%0A                    tween_factory_depends%5Bover%5D = depends = %5B
+%5Bover
 %5D%0A  

Remove unused code in tween sorting.