B
    [[                 @   s0   d dl mZ d dlZdd Zdd Zdd ZdS )	    )OrderedDictNc             C   s    | d d pd| d d f}|S )zReturns appropriate key for sorting attribute names

    Attribute names are a tuple of ``(namespace, name)`` where namespace can be
    ``None`` or a string. These can't be compared in Python 3, so we conver the
    ``None`` to an empty string.

    r        )attrkeyr   r   +lib/python3.7/site-packages/bleach/utils.py	_attr_key   s    r	   c             C   s&   | s| S t dd t|  tdD S )zBTakes a dict of attributes (or None) and returns them alphabetizedc             S   s   g | ]\}}||fqS r   r   ).0kvr   r   r   
<listcomp>   s    z*alphabetize_attributes.<locals>.<listcomp>)r   )r   sorteditemsr	   )Zattrsr   r   r   alphabetize_attributes   s    r   c             C   s   t | tjr| S t| ddS )a   Takes a text (Python 2: str/unicode; Python 3: unicode) and converts to unicode

    :arg str/unicode text: the text in question

    :returns: text as unicode

    :raises UnicodeDecodeError: if the text was a Python 2 str and isn't in
        utf-8

    zutf-8strict)
isinstancesixZ	text_type)textr   r   r   force_unicode   s    r   )collectionsr   r   r	   r   r   r   r   r   r   <module>   s   
