当前位置: 首页>>代码示例>>Python>>正文


Python utils.imt函数代码示例

本文整理汇总了Python中sqlparse.utils.imt函数的典型用法代码示例。如果您正苦于以下问题:Python imt函数的具体用法?Python imt怎么用?Python imt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: group_period

def group_period(tlist):
    lfunc = lambda tk: imt(tk, i=(sql.SquareBrackets, sql.Identifier),
                           t=(T.Name, T.String.Symbol,))

    rfunc = lambda tk: imt(tk, i=(sql.SquareBrackets, sql.Function),
                           t=(T.Name, T.String.Symbol, T.Wildcard))

    _group_left_right(tlist, (T.Punctuation, '.'), sql.Identifier,
                      valid_left=lfunc, valid_right=rfunc)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:9,代码来源:grouping.py

示例2: get_parameters

 def get_parameters(self):
     """Return a list of parameters."""
     parenthesis = self.tokens[-1]
     for token in parenthesis.tokens:
         if imt(token, i=IdentifierList):
             return token.get_identifiers()
         elif imt(token, i=(Function, Identifier), t=T.Literal):
             return [token, ]
     return []
开发者ID:JasonMWhite,项目名称:sqlparse,代码行数:9,代码来源:sql.py

示例3: group_comparison

def group_comparison(tlist):
    I_COMPERABLE = (sql.Parenthesis, sql.Function, sql.Identifier)
    T_COMPERABLE = T_NUMERICAL + T_STRING + T_NAME

    func = lambda tk: imt(tk, t=T_COMPERABLE, i=I_COMPERABLE) or (
        imt(tk, t=T.Keyword) and tk.value.upper() == 'NULL')

    _group_left_right(tlist, (T.Operator.Comparison, None), sql.Comparison,
                      valid_left=func, valid_right=func)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:9,代码来源:grouping.py

示例4: valid

 def valid(token):
     if imt(token, t=ttypes, i=sqlcls):
         return True
     elif token and token.is_keyword and token.normalized == 'NULL':
         return True
     else:
         return False
开发者ID:pombredanne,项目名称:sqlparse,代码行数:7,代码来源:grouping.py

示例5: post

    def post(tlist, pidx, tidx, nidx):
        # next_ validation is being performed here. issue261
        sqlcls = sql.SquareBrackets, sql.Function
        ttypes = T.Name, T.String.Symbol, T.Wildcard
        next_ = tlist[nidx] if nidx is not None else None
        valid_next = imt(next_, i=sqlcls, t=ttypes)

        return (pidx, nidx) if valid_next else (pidx, tidx)
开发者ID:pombredanne,项目名称:sqlparse,代码行数:8,代码来源:grouping.py

示例6: group_functions

def group_functions(tlist):
    token = tlist.token_next_by(t=T.Name)
    while token:
        next_ = tlist.token_next(token)
        if imt(next_, i=sql.Parenthesis):
            tokens = tlist.tokens_between(token, next_)
            token = tlist.group_tokens(sql.Function, tokens)
        token = tlist.token_next_by(t=T.Name, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:8,代码来源:grouping.py

示例7: group_comments

def group_comments(tlist):
    tidx, token = tlist.token_next_by(t=T.Comment)
    while token:
        eidx, end = tlist.token_not_matching(lambda tk: imt(tk, t=T.Comment) or tk.is_whitespace, idx=tidx)
        if end is not None:
            eidx, end = tlist.token_prev(eidx, skip_ws=False)
            tlist.group_tokens(sql.Comment, tidx, eidx)

        tidx, token = tlist.token_next_by(t=T.Comment, idx=tidx)
开发者ID:andialbrecht,项目名称:sqlparse,代码行数:9,代码来源:grouping.py

示例8: group_order

def group_order(tlist):
    """Group together Identifier and Asc/Desc token"""
    token = tlist.token_next_by(t=T.Keyword.Order)
    while token:
        prev = tlist.token_prev(token)
        if imt(prev, i=sql.Identifier, t=T.Number):
            tokens = tlist.tokens_between(prev, token)
            token = tlist.group_tokens(sql.Identifier, tokens)
        token = tlist.token_next_by(t=T.Keyword.Order, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:9,代码来源:grouping.py

示例9: group_order

def group_order(tlist):
    """Group together Identifier and Asc/Desc token"""
    tidx, token = tlist.token_next_by(t=T.Keyword.Order)
    while token:
        pidx, prev_ = tlist.token_prev(tidx)
        if imt(prev_, i=sql.Identifier, t=T.Number):
            tlist.group_tokens(sql.Identifier, pidx, tidx)
            tidx = pidx
        tidx, token = tlist.token_next_by(t=T.Keyword.Order, idx=tidx)
开发者ID:pombredanne,项目名称:sqlparse,代码行数:9,代码来源:grouping.py

示例10: group_arrays

def group_arrays(tlist):
    token = tlist.token_next_by(i=sql.SquareBrackets)
    while token:
        prev = tlist.token_prev(idx=token)
        if imt(prev, i=(sql.SquareBrackets, sql.Identifier, sql.Function),
               t=(T.Name, T.String.Symbol,)):
            tokens = tlist.tokens_between(prev, token)
            token = tlist.group_tokens(sql.Identifier, tokens, extend=True)
        token = tlist.token_next_by(i=sql.SquareBrackets, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:9,代码来源:grouping.py

示例11: token_next

    def token_next(self, idx, skip_ws=True, skip_cm=False):
        """Returns the next token relative to *idx*.

        If *skip_ws* is ``True`` (the default) whitespace tokens are ignored.
        ``None`` is returned if there's no next token.
        """
        if isinstance(idx, int):
            idx += 1  # alot of code usage current pre-compensates for this
        funcs = lambda tk: not ((skip_ws and tk.is_whitespace()) or
                                (skip_cm and imt(tk, t=T.Comment)))
        return self._token_matching(funcs, idx)
开发者ID:JasonMWhite,项目名称:sqlparse,代码行数:11,代码来源:sql.py

示例12: _group_matching

def _group_matching(tlist, cls):
    """Groups Tokens that have beginning and end. ie. parenthesis, brackets.."""
    idx = 1 if imt(tlist, i=cls) else 0

    token = tlist.token_next_by(m=cls.M_OPEN, idx=idx)
    while token:
        end = find_matching(tlist, token, cls.M_OPEN, cls.M_CLOSE)
        if end is not None:
            token = tlist.group_tokens(cls, tlist.tokens_between(token, end))
            _group_matching(token, cls)
        token = tlist.token_next_by(m=cls.M_OPEN, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:11,代码来源:grouping.py

示例13: group_aliased

def group_aliased(tlist):
    I_ALIAS = (sql.Parenthesis, sql.Function, sql.Case, sql.Identifier,
               )  # sql.Operation)

    token = tlist.token_next_by(i=I_ALIAS, t=T.Number)
    while token:
        next_ = tlist.token_next(token)
        if imt(next_, i=sql.Identifier):
            tokens = tlist.tokens_between(token, next_)
            token = tlist.group_tokens(sql.Identifier, tokens, extend=True)
        token = tlist.token_next_by(i=I_ALIAS, t=T.Number, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:11,代码来源:grouping.py

示例14: group_comments

def group_comments(tlist):
    token = tlist.token_next_by(t=T.Comment)
    while token:
        end = tlist.token_not_matching(
            token, lambda tk: imt(tk, t=T.Comment) or tk.is_whitespace())
        if end is not None:
            end = tlist.token_prev(end, False)
            tokens = tlist.tokens_between(token, end)
            token = tlist.group_tokens(sql.Comment, tokens)

        token = tlist.token_next_by(t=T.Comment, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:11,代码来源:grouping.py

示例15: token_first

    def token_first(self, skip_ws=True, skip_cm=False):
        """Returns the first child token.

        If *skip_ws* is ``True`` (the default), whitespace
        tokens are ignored.

        if *skip_cm* is ``True`` (default: ``False``), comments are
        ignored too.
        """
        # this on is inconsistent, using Comment instead of T.Comment...
        funcs = lambda tk: not ((skip_ws and tk.is_whitespace()) or (skip_cm and imt(tk, t=T.Comment, i=Comment)))
        return self._token_matching(funcs)[1]
开发者ID:roofcat,项目名称:dtracking,代码行数:12,代码来源:sql.py


注:本文中的sqlparse.utils.imt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。