B
    `S
                 @   sB   d dl mZmZ d dlmZ dddZdddZdefd	d
ZdS )    )quote
quote_plus)is_nonstr_iter c             C   s<   | j }|tkr| d} n|tk	r0t| d} t| |dS )Nzutf-8)safe)	__class__strencodebytes
_url_quote)valr   cls r   V/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pyramid/encode.py	url_quote   s    r   c             C   s<   | j }|tkr| d} n|tk	r0t| d} t| |dS )Nzutf-8)r   )r   r   r	   r
   _quote_plus)r   r   r   r   r   r   r      s    r   Tc             C   s   y|   } W n tk
r    Y nX d}d}x| D ]~\}}||}t|rvx`|D ]"}||}|d|||f 7 }d}qNW n4|dkr|d||f 7 }n||}|d|||f 7 }d}q0W |S )a  
    An alternate implementation of Python's stdlib
    :func:`urllib.parse.urlencode` function which accepts string keys and
    values within the ``query`` dict/sequence; all string keys and values are
    first converted to UTF-8 before being used to compose the query string.

    The value of ``query`` must be a sequence of two-tuples
    representing key/value pairs *or* an object (often a dictionary)
    with an ``.items()`` method that returns a sequence of two-tuples
    representing key/value pairs.

    For minimal calling convention backwards compatibility, this
    version of urlencode accepts *but ignores* a second argument
    conventionally named ``doseq``.  The Python stdlib version behaves
    differently when ``doseq`` is False and when a sequence is
    presented as one of the values.  This version always behaves in
    the ``doseq=True`` mode, no matter what the value of the second
    argument.

    Both the key and value are encoded using the ``quote_via`` function which
    by default is using a similar algorithm to :func:`urllib.parse.quote_plus`
    which converts spaces into '+' characters and '/' into '%2F'.

    .. versionchanged:: 1.5
       In a key/value pair, if the value is ``None`` then it will be
       dropped from the resulting output.

    .. versionchanged:: 1.9
       Added the ``quote_via`` argument to allow alternate quoting algorithms
       to be used.

    r   z%s%s=%s&Nz%s%s=)itemsAttributeErrorr   )querydoseq	quote_viaresultprefixkvxr   r   r   	urlencode   s&    !

r   N)r   )r   )	urllib.parser   r   r   r   Zpyramid.utilr   r   r   r   r   r   r   <module>   s   


	