U
    Ø’É]Ô  ã                   @   s$   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 }t | ƒD ].}t |ƒD ] }||krd||< | d|¡ qq|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   s2   | g}d}t |ƒD ]} |d7 }| j|||…< q|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   