3
7ßL]Ý  ã               @   s$   d Z ddlmZ G dd„ deƒZdS )z Base class for all sorters. é    )Ú	HasTraitsc               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚSorterz& Abstract base class for all sorters. c                s   ‡ ‡‡fdd„}|j |ƒ |S )a   Sorts a list of nodes IN PLACE.

        'widget' is the widget that we are sorting nodes for.
        'parent' is the parent node.
        'nodes'  is the list of nodes to sort.

        Returns the list that was sorted IN PLACE (for convenience).

        c                s   ˆj ˆˆ | |ƒS )z Comparator. )Úcompare)Únode_aÚnode_b)ÚparentÚselfÚwidget© ú1/tmp/pip-install-5sebvq2j/pyface/pyface/sorter.pyÚ
comparator)   s    zSorter.sort.<locals>.comparator)Úsort)r   r	   r   Znodesr   r
   )r   r   r	   r   r      s    
zSorter.sortc       
      C   sV   | j |||ƒ}| j |||ƒ}||kr0t||ƒ}n"|jj|ƒ}|jj|ƒ}	t||	ƒ}|S )a    Returns the result of comparing two nodes.

        'widget' is the widget that we are sorting nodes for.
        'parent' is the parent node.
        'node_a' is the the first node to compare.
        'node_b' is the the second node to compare.

        )ÚcategoryÚcmpÚmodelZget_text)
r   r	   r   r   r   Z
category_aZ
category_bÚresultZlabel_aZlabel_br
   r
   r   r   2   s    
zSorter.comparec             C   s   dS )a£   Returns the category (an integer) for an node.

        'parent' is the parent node.
        'nodes'  is the node to return the category for.

        Categories are used to sort nodes into bins.  The bins are arranged in
        ascending numeric order.  The nodes within a bin are arranged as
        dictated by the sorter's 'compare' method.

        By default all nodes are given the same category (0).

        r   r
   )r   r	   r   Únoder
   r
   r   r   N   s    zSorter.categoryc             C   s   dS )a6   Is the sorter affected by changes to a node's trait?

        'node'       is the node.
        'trait_name' is the name of the trait.

        Returns True if the sorter would be affected by changes to the trait
        named 'trait_name' on the specified node.

        By default we return False.

        Fr
   )r   r   Z
trait_namer
   r
   r   Úis_sorter_trait^   s    zSorter.is_sorter_traitN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r
   r
   r
   r   r      s
   r   N)r   Z
traits.apir   r   r
   r
   r
   r   Ú<module>   s   