當前位置: 首頁>>代碼示例>>Python>>正文


Python ast.projection方法代碼示例

本文整理匯總了Python中jmespath.ast.projection方法的典型用法代碼示例。如果您正苦於以下問題:Python ast.projection方法的具體用法?Python ast.projection怎麽用?Python ast.projection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jmespath.ast的用法示例。


在下文中一共展示了ast.projection方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _token_nud_lbracket

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [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: _token_led_lbracket

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [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

示例3: _parse_projection_rhs

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [as 別名]
def _parse_projection_rhs(self, binding_power):
        # Parse the right hand side of the projection.
        if self.BINDING_POWER[self._current_token()] < self._PROJECTION_STOP:
            # BP of 10 are all the tokens that stop a projection.
            right = ast.identity()
        elif self._current_token() == 'lbracket':
            right = self._expression(binding_power)
        elif self._current_token() == 'filter':
            right = self._expression(binding_power)
        elif self._current_token() == 'dot':
            self._match('dot')
            right = self._parse_dot_rhs(binding_power)
        else:
            self._raise_parse_error_for_token(self._lookahead_token(0),
                                              'syntax error')
        return right 
開發者ID:skarlekar,項目名稱:faces,代碼行數:18,代碼來源:parser.py

示例4: _parse_projection_rhs

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [as 別名]
def _parse_projection_rhs(self, binding_power):
        # Parse the right hand side of the projection.
        if self.BINDING_POWER[self._current_token()] < self._PROJECTION_STOP:
            # BP of 10 are all the tokens that stop a projection.
            right = ast.identity()
        elif self._current_token() == 'lbracket':
            right = self._expression(binding_power)
        elif self._current_token() == 'filter':
            right = self._expression(binding_power)
        elif self._current_token() == 'dot':
            self._match('dot')
            right = self._parse_dot_rhs(binding_power)
        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')
        return right 
開發者ID:awslabs,項目名稱:mxnet-lambda,代碼行數:22,代碼來源:parser.py

示例5: _parse_projection_rhs

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [as 別名]
def _parse_projection_rhs(self, binding_power):
        # Parse the right hand side of the projection.
        if self.BINDING_POWER[self._current_token()] < 10:
            # BP of 10 are all the tokens that stop a projection.
            right = ast.identity()
        elif self._current_token() == 'lbracket':
            right = self._expression(binding_power)
        elif self._current_token() == 'filter':
            right = self._expression(binding_power)
        elif self._current_token() == 'dot':
            self._match('dot')
            right = self._parse_dot_rhs(binding_power)
        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')
        return right 
開發者ID:TencentCloud,項目名稱:tencentcloud-cli,代碼行數:22,代碼來源:parser.py

示例6: _token_nud_flatten

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [as 別名]
def _token_nud_flatten(self, token):
        left = ast.flatten(ast.identity())
        right = self._parse_projection_rhs(
            self.BINDING_POWER['flatten'])
        return ast.projection(left, right) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:7,代碼來源:parser.py

示例7: _token_led_dot

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [as 別名]
def _token_led_dot(self, left):
        if not self._current_token() == 'star':
            right = self._parse_dot_rhs(self.BINDING_POWER['dot'])
            if left['type'] == 'subexpression':
                left['children'].append(right)
                return left
            else:
                return ast.subexpression([left, right])
        else:
            # We're creating a projection.
            self._advance()
            right = self._parse_projection_rhs(
                self.BINDING_POWER['dot'])
            return ast.value_projection(left, right) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:16,代碼來源:parser.py

示例8: _token_led_flatten

# 需要導入模塊: from jmespath import ast [as 別名]
# 或者: from jmespath.ast import projection [as 別名]
def _token_led_flatten(self, left):
        left = ast.flatten(left)
        right = self._parse_projection_rhs(
            self.BINDING_POWER['flatten'])
        return ast.projection(left, right) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:7,代碼來源:parser.py


注:本文中的jmespath.ast.projection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。