• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.imt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: group_identifier_list

def group_identifier_list(tlist):
    I_IDENT_LIST = (sql.Function, sql.Case, sql.Identifier, sql.Comparison,
                    sql.IdentifierList)  # sql.Operation
    T_IDENT_LIST = (T_NUMERICAL + T_STRING + T_NAME +
                    (T.Keyword, T.Comment, T.Wildcard))

    func = lambda t: imt(t, i=I_IDENT_LIST, m=M_ROLE, t=T_IDENT_LIST)
    token = tlist.token_next_by(m=M_COMMA)

    while token:
        before, after = tlist.token_prev(token), tlist.token_next(token)

        if func(before) and func(after):
            tokens = tlist.tokens_between(before, after)
            token = tlist.group_tokens(sql.IdentifierList, tokens, extend=True)
        token = tlist.token_next_by(m=M_COMMA, idx=token)
开发者ID:dagwieers,项目名称:sqlparse,代码行数:16,代码来源:grouping.py


示例17: group_functions

def group_functions(tlist):
    has_create = False
    has_table = False
    for tmp_token in tlist.tokens:
        if tmp_token.value == 'CREATE':
            has_create = True
        if tmp_token.value == 'TABLE':
            has_table = True
    if has_create and has_table:
        return
    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:JasonMWhite,项目名称:sqlparse,代码行数:17,代码来源:grouping.py


示例18: group_operator

def group_operator(tlist):
    I_CYCLE = (sql.SquareBrackets, sql.Parenthesis, sql.Function,
               sql.Identifier,)  # sql.Operation)
    # wilcards wouldn't have operations next to them
    T_CYCLE = T_NUMERICAL + T_STRING + T_NAME  # + T.Wildcard
    func = lambda tk: imt(tk, i=I_CYCLE, t=T_CYCLE)

    token = tlist.token_next_by(t=(T.Operator, T.Wildcard))
    while token:
        left, right = tlist.token_prev(token), tlist.token_next(token)

        if func(left) and func(right):
            token.ttype = T.Operator
            tokens = tlist.tokens_between(left, right)
            # token = tlist.group_tokens(sql.Operation, tokens)
            token = tlist.group_tokens(sql.Identifier, tokens)

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


示例19: valid_prev

 def valid_prev(token):
     sqlcls = sql.SquareBrackets, sql.Identifier
     ttypes = T.Name, T.String.Symbol
     return imt(token, i=sqlcls, t=ttypes)
开发者ID:pombredanne,项目名称:sqlparse,代码行数:4,代码来源:grouping.py


示例20: match

 def match(token):
     return imt(token, t=(T.Operator, T.Wildcard))
开发者ID:pombredanne,项目名称:sqlparse,代码行数:2,代码来源:grouping.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sqltap.start函数代码示例发布时间:2022-05-27
下一篇:
Python lexer.tokenize函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap