U
    I+|j9
  ã                   @   s  d Z ddlmZmZmZmZmZmZ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eee ee
jdf dœdd„Zd eeee f ee ee
jddf dœdd„Zd!eee eedœdd„Zd"eee eee dœdd„ZdS )#zParse SQL statements.é    )ÚAnyÚ	GeneratorÚIOÚListÚOptionalÚTupleÚUnion)Úsql)Úcli)Úengine)Útokens)Úfilters)Ú	formatterz0.5.5r   r   r   r	   r   r
   N.)r	   ÚencodingÚreturnc                 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	   r   © r   úYc:\users\snmko\desktop\web_content\django_cbt\venv\Lib\site-packages\sqlparse/__init__.pyÚparse   s    	r   )Ústreamr   r   c                 C   s   t  ¡ }| ¡  | | |¡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)r   r   Ústackr   r   r   r   %   s    	r   )r	   r   Úoptionsr   c                 K   s@   t  ¡ }t |¡}t ||¡}|j t ¡ ¡ d 	| 
| |¡¡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_stackÚpostprocessÚappendr   ZSerializerUnicodeÚjoinr   )r	   r   r   r   r   r   r   Úformat3   s
    

r   F)r	   r   Ústrip_semicolonr   c                 C   s"   t j|d�}dd„ | | |¡D ƒS )a#  Split *sql* into single statements.

    :param sql: A string containing one or more SQL statements.
    :param encoding: The encoding of the statement (optional).
    :param strip_semicolon: If True, remove trailing semicolons
        (default: False).
    :returns: A list of strings.
    )r    c                 S   s   g | ]}t |ƒ ¡ ‘qS r   )ÚstrÚstrip)Ú.0Zstmtr   r   r   Ú
<listcomp>P   s     zsplit.<locals>.<listcomp>)r   r   r   )r	   r   r    r   r   r   r   ÚsplitD   s    r%   )N)N)N)NF)Ú__doc__Útypingr   r   r   r   r   r   r   Zsqlparser	   r
   r   r   r   r   Ú__version__Ú__all__r!   Z	Statementr   r   r   Úboolr%   r   r   r   r   Ú<module>   s<   $ ÿ þ ÿ þ   ÿ  þ