ó
Ð²Ebc           @   s_   d  d l  m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d	 S(
   i   (   t   collections_abct   DirectedGraphc           B   sz   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z RS(   s&   A graph structure with directed edges.c         C   s"   t  ƒ  |  _ i  |  _ i  |  _ d  S(   N(   t   sett	   _verticest	   _forwardst
   _backwards(   t   self(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   __init__   s    	c         C   s   t  |  j ƒ S(   N(   t   iterR   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   __iter__   s    c         C   s   t  |  j ƒ S(   N(   t   lenR   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   __len__   s    c         C   s   | |  j  k S(   N(   R   (   R   t   key(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   __contains__   s    c         C   sW   t  ƒ  } t |  j ƒ | _ d „  |  j j ƒ  Dƒ | _ d „  |  j j ƒ  Dƒ | _ | S(   s$   Return a shallow copy of this graph.c         S   s%   i  |  ] \ } } t  | ƒ | “ q S(    (   R   (   t   .0t   kt   v(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pys
   <dictcomp>   s   	 c         S   s%   i  |  ] \ } } t  | ƒ | “ q S(    (   R   (   R   R   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pys
   <dictcomp>   s   	 (   R   R   R   R   t   itemsR   (   R   t   other(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   copy   s
    	c         C   sR   | |  j  k r t d ƒ ‚ n  |  j  j | ƒ t ƒ  |  j | <t ƒ  |  j | <d S(   s   Add a new vertex to the graph.s   vertex existsN(   R   t
   ValueErrort   addR   R   R   (   R   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR      s
    c         C   sv   |  j  j | ƒ x. |  j j | ƒ D] } |  j | j | ƒ q# Wx. |  j j | ƒ D] } |  j | j | ƒ qT Wd S(   sC   Remove a vertex from the graph, disconnecting all edges from/to it.N(   R   t   removeR   t   popR   (   R   R   t   ft   t(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR   %   s
    c         C   s$   | |  j  | k o# | |  j | k S(   N(   R   R   (   R   R   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt	   connected-   s    c         C   sJ   | |  j  k r t | ƒ ‚ n  |  j | j | ƒ |  j | j | ƒ d S(   sg   Connect two existing vertices.

        Nothing happens if the vertices are already connected.
        N(   R   t   KeyErrorR   R   R   (   R   R   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   connect0   s    c         c   s@   x9 |  j  j ƒ  D]( \ } } x | D] } | | f Vq# Wq Wd  S(   N(   R   R   (   R   R   t   childrenR   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt
   iter_edges:   s    c         C   s   t  |  j | ƒ S(   N(   R   R   (   R   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   iter_children?   s    c         C   s   t  |  j | ƒ S(   N(   R   R   (   R   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   iter_parentsB   s    (   t   __name__t
   __module__t   __doc__R   R	   R   R   R   R   R   R   R   R   R   R    (    (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR      s   									
		t   _FactoryIterableViewc           B   sJ   e  Z d  Z d „  Z d „  Z d „  Z e Z d „  Z d „  Z d „  Z	 RS(   s:  Wrap an iterator factory returned by `find_matches()`.

    Calling `iter()` on this class would invoke the underlying iterator
    factory, making it a "collection with ordering" that can be iterated
    through multiple times, but lacks random access methods presented in
    built-in Python sequence types.
    c         C   s   | |  _  d  S(   N(   t   _factory(   R   t   factory(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR   O   s    c         C   s%   d j  t |  ƒ j t |  j ƒ  ƒ ƒ S(   Ns   {}({})(   t   formatt   typeR!   t   listR%   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   __repr__R   s    c         C   s-   y t  |  j ƒ  ƒ Wn t k
 r( t SXt S(   N(   t   nextR%   t   StopIterationt   Falset   True(   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   __bool__U   s
    c         C   s
   |  j  ƒ  S(   N(   R%   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR	   ^   s    c         C   s
   |  j  ƒ  S(   s4   Provide an candidate iterable for `get_preference()`(   R%   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   for_preferencea   s    c            s"   ‡  ‡ f d †  } t  ˆ ƒ | ƒ S(   s5   Create a new instance excluding specified candidates.c              s   ‡  f d †  ˆ j  ƒ  Dƒ S(   Nc         3   s!   |  ] } | ˆ  k r | Vq d  S(   N(    (   R   t   c(   t
   candidates(    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pys	   <genexpr>i   s    (   R%   (    (   R2   R   (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR&   h   s    (   R(   (   R   R2   R&   (    (   R2   R   s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt	   excludinge   s    (
   R!   R"   R#   R   R*   R/   t   __nonzero__R	   R0   R3   (    (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR$   F   s   					t   _SequenceIterableViewc           B   sS   e  Z d  Z d „  Z d „  Z d „  Z e Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   s²   Wrap an iterable returned by find_matches().

    This is essentially just a proxy to the underlying sequence that provides
    the same interface as `_FactoryIterableView`.
    c         C   s   | |  _  d  S(   N(   t	   _sequence(   R   t   sequence(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR   u   s    c         C   s   d j  t |  ƒ j |  j ƒ S(   Ns   {}({})(   R'   R(   R!   R6   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR*   x   s    c         C   s   t  |  j ƒ S(   N(   t   boolR6   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR/   {   s    c         C   s   t  |  j ƒ S(   N(   R   R6   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR	   €   s    c         C   s   t  |  j ƒ S(   N(   R
   R6   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR   ƒ   s    c         C   s   |  j  S(   s4   Provide an candidate iterable for `get_preference()`(   R6   (   R   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR0   †   s    c         C   s2   t  |  ƒ g  |  j D] } | | k r | ^ q ƒ S(   s5   Create a new instance excluding specified candidates.(   R(   R6   (   R   R2   R1   (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR3   Š   s    (   R!   R"   R#   R   R*   R/   R4   R	   R   R0   R3   (    (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyR5   n   s   						c         C   sA   t  |  ƒ r t |  ƒ St |  t j ƒ s7 t |  ƒ }  n  t |  ƒ S(   sC   Build an iterable view from the value returned by `find_matches()`.(   t   callableR$   t
   isinstanceR    t   SequenceR)   R5   (   t   matches(    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   build_iter_view   s
    
N(   t   compatR    t   objectR   R$   R5   R=   (    (    (    s;   /tmp/pip-build-UPPWic/pip/pip/_vendor/resolvelib/structs.pyt   <module>   s   B(!