3
vÅÏ^É  ã               @   s˜   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 d	Z
d
dddddgZddd„Zddd„Zddd„Zddd„ZdS )zParse SQL statements.é    )Úsql)Úcli)Úengine)Útokens)Úfilters)Ú	formatter)Ú	text_typez0.3.1r   r   r   r   r   r   Nc             C   s   t t| |ƒƒS )zôParse sql and return a list of statements.

    :param sql: A string containing one or more SQL statements.
    :param encoding: The encoding of the statement (optional).
    :returns: A tuple of :class:`~sqlparse.sql.Statement` instances.
    )ÚtupleÚparsestream)r   Úencoding© r   ú5/usr/lib/python3.6/site-packages/sqlparse/__init__.pyÚparse   s    r   c             C   s   t jƒ }|jƒ  |j| |ƒS )zçParses sql statements from file-like object.

    :param stream: A file-like object.
    :param encoding: The encoding of the stream contents (optional).
    :returns: A generator of :class:`~sqlparse.sql.Statement` instances.
    )r   ÚFilterStackZenable_groupingÚrun)Ústreamr   Ústackr   r   r   r
   #   s    r
   c             K   s@   t jƒ }tj|ƒ}tj||ƒ}|jjtjƒ ƒ dj	|j
| |ƒƒS )a'  Format *sql* according to *options*.

    Available options are documented in :ref:`formatting`.

    In addition to the formatting options this function accepts the
    keyword "encoding" which determines the encoding of the statement.

    :returns: The formatted SQL statement as string.
    Ú )r   r   r   Zvalidate_optionsZbuild_filter_stackZpostprocessÚappendr   ZSerializerUnicodeÚjoinr   )r   r   Úoptionsr   r   r   r   Úformat/   s
    

r   c             C   s   t jƒ }dd„ |j| |ƒD ƒS )zÉSplit *sql* into single statements.

    :param sql: A string containing one or more SQL statements.
    :param encoding: The encoding of the statement (optional).
    :returns: A list of strings.
    c             S   s   g | ]}t |ƒjƒ ‘qS r   )r   Ústrip)Ú.0Ústmtr   r   r   ú
<listcomp>H   s    zsplit.<locals>.<listcomp>)r   r   r   )r   r   r   r   r   r   Úsplit@   s    r   )N)N)N)N)Ú__doc__Úsqlparser   r   r   r   r   r   Zsqlparse.compatr   Ú__version__Ú__all__r   r
   r   r   r   r   r   r   Ú<module>	   s   



