o
    svXjµ  ã                   @   s–   d dl Z d dlZd dlmZ d dlmZ d dlmZ e dej	¡Z
e 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)Úcontextmanager)Ú	text_typeaZ  
(
 (?:                     # 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   sR   t | ƒ}t |¡}dg}|D ]}|sqt |¡r| d¡ q|d  |7  < q|S )z™Split 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.Ú éÿÿÿÿ)r   ÚSPLIT_REGEXÚsplitÚ
LINE_MATCHÚmatchÚappend)ÚstmtÚtextÚlinesÚoutputlinesÚline© r   úK/var/www/html/myproject/venv/lib/python3.10/site-packages/sqlparse/utils.pyÚsplit_unquoted_newlines&   s   

r   c                 C   s8   | du rdS | d dv r| d | d kr| dd… } | S )z4Helper that removes surrounding quotes from strings.Nr   )ú"ú'r   é   r   )Úvalr   r   r   Úremove_quotes8   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                    s,   |   ¡ D ]}t|ˆ ƒsˆ|ƒ qˆ| ƒ d S ©N)Úget_sublistsÚ
isinstance)ÚtlistÚsgroup)ÚclsÚfÚ	wrapped_fr   r   r    H   s
   
€z(recurse.<locals>.wrap.<locals>.wrapped_fr   )r   ©r   )r   r    r   ÚwrapG   s   zrecurse.<locals>.wrapr   )r   r"   r   r!   r   ÚrecurseA   s   	r#   c                    s’   |}|rt |tƒs|gn|}|rt |tƒs|gn|}ˆ du r dS |r)t ˆ |ƒr)dS |r8t‡ fdd„|D ƒƒr8dS |rGt‡ fdd„|D ƒƒrGd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 r   )r
   )Ú.0Úpattern©Útokenr   r   Ú	<genexpr>c   ó   € zimt.<locals>.<genexpr>c                 3   s   � | ]}ˆ j |v V  qd S r   )Úttype)r$   r*   r&   r   r   r(   e   r)   )r   ÚlistÚany)r'   ÚiÚmÚtÚclssÚtypesÚ	mpatternsr   r&   r   ÚimtS   s   r3   c                 C   s   t t | |¡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   Úconsumek   s   r9   c                 c   ó(   � |  j |7  _ d V  |  j |8  _ d S r   )Úoffset©Úfilter_r8   r   r   r   r;   p   ó   €r;   r   c                 c   r:   r   )Úindentr<   r   r   r   r?   w   r>   r?   )NNN)r   )r   )r5   ÚreÚcollectionsr   Ú
contextlibr   Úsqlparse.compatr   ÚcompileÚVERBOSEr   r	   r   r   r#   r3   r9   r;   r?   r   r   r   r   Ú<module>   s$   

ö
	
