Ńň
4×ŰQc           @   s?   d  Z  d e f d     YZ d e f d     YZ d   Z d S(   sC   
toposort.py
Sorts dictionary keys based on lists of dependencies.
t   MissingDependencyc           B   s   e  Z d  Z RS(   sC   Exception raised when a listed dependency is not in the dictionary.(   t   __name__t
   __module__t   __doc__(    (    (    s   ../tools\toposort.pyR       s   t   Sorterc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s"   | |  _  t   |  _ d |  _ d  S(   N(    (   t   dependenciest   sett   visitedt   sorted(   t   selfR   (    (    s   ../tools\toposort.pyt   __init__
   s    	c         C   s(   x |  i  D] } |  i |  q
 W|  i S(   N(   R   t   _visitR   (   R	   t   key(    (    s   ../tools\toposort.pyt   sort   s    
 c         C   s   | |  i  j on |  i  i |  |  i i |  p t |   n x" |  i | D] } |  i |  qQ W|  i | f 7_ n d  S(   N(   R   t   addR   t   has_keyR    R   R   (   R	   R   t   depends(    (    s   ../tools\toposort.pyR      s     (   R   R   R
   R   R   (    (    (    s   ../tools\toposort.pyR   	   s   		c         C   s   t  |   } | i   S(   sŐ   Returns a tuple of the dependencies dictionary keys sorted by entries
    in the dependency lists.  Given circular dependencies, sort will impose
    an order.  Raises MissingDependency if a key is not found.
    (   R   R   (   R   t   s(    (    s   ../tools\toposort.pyt   toposort   s    N(   R   t	   ExceptionR    t   objectR   R   (    (    (    s   ../tools\toposort.pyt   <module>   s   