o e}_q @sddlZddlZddlmZddlmZedejZedZ ddZ dd Z d d Z dd d Z ddZedddZedddZdS)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)cCsRt|}t|}dg}|D]}|sqt|r|dq|d|7<q|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_REGEXsplit LINE_MATCHmatchappend)stmttextlines outputlinesliner0/usr/lib/python3/dist-packages/sqlparse/utils.pysplit_unquoted_newlines$s   rcCs8|durdS|ddvr|d|dkr|dd}|S)z4Helper that removes surrounding quotes from strings.Nr)"'rr)valrrr remove_quotes6s  rcsfdd}|S)zqFunction decorator to help with recursion :param cls: Classes to not recurse over :return: function csfddS)Ncs,|D] }t|s|q|dSN) get_sublists isinstance)tlistsgroup)clsf wrapped_frrr Fs   z(recurse..wrap..wrapped_fr)rr)rr rwrapEszrecurse..wrapr)rr"rr!rrecurse?s  r#cs|}|r t|ts |gn|}|rt|ts|gn|}dur dS|r)t|r)dS|r8tfdd|Dr8dS|rGtfdd|DrGdSdS)aHelper 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 NFTc3s|]}j|VqdSr)r ).0patterntokenrr azimt..c3s|]}j|vVqdSr)ttype)r$r*r&rrr(cr))rlistany)r'imtclsstypes mpatternsrr&rimtQsr3cCstt||dddS)zCAdvance the iterator n-steps ahead. If n is none, consume entirely.r)maxlenN)r itertoolsislice)iteratornrrrconsumeisr9cc(|j|7_dV|j|8_dSr)offsetfilter_r8rrrr;nr;rccr:r)indentr<rrrr?ur>r?)NNN)r)r)r5re collectionsr contextlibrcompileVERBOSErr rrr#r3r9r;r?rrrrs"