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


Python ast.index方法代码示例

本文整理汇总了Python中jmespath.ast.index方法的典型用法代码示例。如果您正苦于以下问题:Python ast.index方法的具体用法?Python ast.index怎么用?Python ast.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jmespath.ast的用法示例。


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

示例1: _token_nud_lbracket

# 需要导入模块: from jmespath import ast [as 别名]
# 或者: from jmespath.ast import index [as 别名]
def _token_nud_lbracket(self, token):
        if self._current_token() in ['number', 'colon']:
            right = self._parse_index_expression()
            # We could optimize this and remove the identity() node.
            # We don't really need an index_expression node, we can
            # just use emit an index node here if we're not dealing
            # with a slice.
            return self._project_if_slice(ast.identity(), right)
        elif self._current_token() == 'star' and \
                self._lookahead(1) == 'rbracket':
            self._advance()
            self._advance()
            right = self._parse_projection_rhs(self.BINDING_POWER['star'])
            return ast.projection(ast.identity(), right)
        else:
            return self._parse_multi_select_list() 
开发者ID:skarlekar,项目名称:faces,代码行数:18,代码来源:parser.py

示例2: _parse_slice_expression

# 需要导入模块: from jmespath import ast [as 别名]
# 或者: from jmespath.ast import index [as 别名]
def _parse_slice_expression(self):
        # [start:end:step]
        # Where start, end, and step are optional.
        # The last colon is optional as well.
        parts = [None, None, None]
        index = 0
        current_token = self._current_token()
        while not current_token == 'rbracket' and index < 3:
            if current_token == 'colon':
                index += 1
                if index == 3:
                    self._raise_parse_error_for_token(
                        self._lookahead_token(0), 'syntax error')
                self._advance()
            elif current_token == 'number':
                parts[index] = self._lookahead_token(0)['value']
                self._advance()
            else:
                self._raise_parse_error_for_token(
                    self._lookahead_token(0), 'syntax error')
            current_token = self._current_token()
        self._match('rbracket')
        return ast.slice(*parts) 
开发者ID:skarlekar,项目名称:faces,代码行数:25,代码来源:parser.py

示例3: _token_led_lbracket

# 需要导入模块: from jmespath import ast [as 别名]
# 或者: from jmespath.ast import index [as 别名]
def _token_led_lbracket(self, left):
        token = self._lookahead_token(0)
        if token['type'] in ['number', 'colon']:
            right = self._parse_index_expression()
            if left['type'] == 'index_expression':
                # Optimization: if the left node is an index expr,
                # we can avoid creating another node and instead just add
                # the right node as a child of the left.
                left['children'].append(right)
                return left
            else:
                return self._project_if_slice(left, right)
        else:
            # We have a projection
            self._match('star')
            self._match('rbracket')
            right = self._parse_projection_rhs(self.BINDING_POWER['star'])
            return ast.projection(left, right) 
开发者ID:skarlekar,项目名称:faces,代码行数:20,代码来源:parser.py

示例4: _parse_slice_expression

# 需要导入模块: from jmespath import ast [as 别名]
# 或者: from jmespath.ast import index [as 别名]
def _parse_slice_expression(self):
        # [start:end:step]
        # Where start, end, and step are optional.
        # The last colon is optional as well.
        parts = [None, None, None]
        index = 0
        current_token = self._current_token()
        while not current_token == 'rbracket' and index < 3:
            if current_token == 'colon':
                index += 1
                self._advance()
            elif current_token == 'number':
                parts[index] = self._lookahead_token(0)['value']
                self._advance()
            else:
                t = self._lookahead_token(0)
                lex_position = t['start']
                actual_value = t['value']
                actual_type = t['type']
                raise exceptions.ParseError(lex_position, actual_value,
                                            actual_type, 'syntax error')
            current_token = self._current_token()
        self._match('rbracket')
        return ast.slice(*parts) 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:26,代码来源:parser.py

示例5: _parse_index_expression

# 需要导入模块: from jmespath import ast [as 别名]
# 或者: from jmespath.ast import index [as 别名]
def _parse_index_expression(self):
        # We're here:
        # [<current>
        #  ^
        #  | current token
        if (self._lookahead(0) == 'colon' or
                self._lookahead(1) == 'colon'):
            return self._parse_slice_expression()
        else:
            # Parse the syntax [number]
            node = ast.index(self._lookahead_token(0)['value'])
            self._advance()
            self._match('rbracket')
            return node 
开发者ID:skarlekar,项目名称:faces,代码行数:16,代码来源:parser.py


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