3
gv                 @   s   d dl Z d dlZd dlmZ d dlmZ ejdejZejdZ	dd Z
dd	 Zd
d ZdddZdd ZedddZedddZdS )    N)deque)contextmanageraZ  
(
 (?:                     # Start of non-capturing group
  (?:\r\n|\r|\n)      |  # Match any single newline, or
  [^\r\n'"]+          |  # Match any character series without quotes or
                         # newlines, or
  "(?:[^"\\]|\\.)*"   |  # Match double-quoted strings, or
  '(?:[^'\\]|\\.)*'      # Match single quoted strings
 )
)
z(\r\n|\r|\n)c             C   sX   t | }tj|}dg}x:|D ]2}|s*qqtj|r@|jd q|d  |7  < qW |S )zSplit a string on all unquoted newlines.

    Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite
    character is inside of a string.    )strSPLIT_REGEXsplit
LINE_MATCHmatchappend)stmttextlinesZoutputlinesline r   L/var/www/tester-filtro-web/env/lib/python3.6/site-packages/sqlparse/utils.pysplit_unquoted_newlines$   s    


r   c             C   s8   | dkrdS | d dkr4| d | d kr4| dd	 } | S )
z4Helper that removes surrounding quotes from strings.Nr   "'`r   )r   r   r   r   r   r   )valr   r   r   remove_quotes6   s
    r   c                 s    fdd}|S )zqFunction decorator to help with recursion

    :param cls: Classes to not recurse over
    :return: function
    c                s    fddS )Nc                s0   x"| j  D ]}t| s
| q
W |  d S )N)Zget_sublists
isinstance)ZtlistZsgroup)clsf	wrapped_fr   r   r   F   s    
z(recurse.<locals>.wrap.<locals>.wrapped_fr   )r   )r   )r   r   r   wrapE   s    zrecurse.<locals>.wrapr   )r   r   r   )r   r   recurse?   s    	r   c                s   |}|rt |t r|gn|}|r4t |t r4|gn|} dkrDdS |rVt  |rVdS |rtt fdd|D rtdS |rt fdd|D rdS dS dS )a  Helper function to simplify comparisons Instance, Match and TokenType
    :param token:
    :param i: Class or Tuple/List of Classes
    :param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
    :param t: TokenType or Tuple/List of TokenTypes
    :return:  bool
    NFTc             3   s   | ]} j | V  qd S )N)r   ).0pattern)tokenr   r   	<genexpr>a   s    zimt.<locals>.<genexpr>c             3   s   | ]} j |kV  qd S )N)ttype)r   r#   )r!   r   r   r"   c   s    )r   listany)r!   imtZclsstypesZ	mpatternsr   )r!   r   imtQ   s    r*   c             C   s   t tj| |dd dS )zCAdvance the iterator n-steps ahead. If n is none, consume entirely.r   )maxlenN)r   	itertoolsislice)iteratornr   r   r   consumei   s    r0   c             c   s&   |  j |7  _ d V  |  j |8  _ d S )N)offset)filter_r/   r   r   r   r1   n   s    r1   r   c             c   s&   |  j |7  _ d V  |  j |8  _ d S )N)indent)r2   r/   r   r   r   r3   u   s    r3   )NNN)r   )r   )r,   recollectionsr   
contextlibr   compileVERBOSEr   r
   r   r   r   r*   r0   r1   r3   r   r   r   r   <module>   s   



	
