
|ÍWÔ  ã               @   s4   d  Z  d Z d d „  Z d d „  Z d d „  Z d S)	z7Compute a resolution order for an object and its bases
Zrestructuredtextc             C   sd   i  } g  } xQ t  |  ƒ D]C } x: t  | ƒ D], } | | k r, d | | <| j d | ƒ q, Wq W| S)a¡  Merge multiple orderings so that within-ordering order is preserved

    Orderings are constrained in such a way that if an object appears
    in two or more orderings, then the suffix that begins with the
    object must be in both orderings.

    For example:

    >>> _mergeOrderings([
    ... ['x', 'y', 'z'],
    ... ['q', 'z'],
    ... [1, 3, 5],
    ... ['z']
    ... ])
    ['x', 'y', 'q', 1, 3, 5, 'z']

    é   é    )ÚreversedÚinsert)Z	orderingsÚseenÚresultZorderingÚo© r   ú3/usr/lib/python3/dist-packages/zope/interface/ro.pyÚ_mergeOrderings   s    
r
   c             C   sG   |  g } d } x1 t  | ƒ D]# }  | d 7} |  j | | | … <q W| S)Nr   r   )ÚiterÚ	__bases__)Úobr   Úir   r   r	   Ú_flatten/   s    	
r   c             C   s   t  t |  ƒ g ƒ S)z/Compute a "resolution order" for an object
    )r
   r   )Úobjectr   r   r	   Úro=   s    r   N)Ú__doc__Z__docformat__r
   r   r   r   r   r   r	   Ú<module>   s   