本文整理汇总了Python中jmespath.exceptions.IncompleteExpressionError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.IncompleteExpressionError方法的具体用法?Python exceptions.IncompleteExpressionError怎么用?Python exceptions.IncompleteExpressionError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jmespath.exceptions
的用法示例。
在下文中一共展示了exceptions.IncompleteExpressionError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _match
# 需要导入模块: from jmespath import exceptions [as 别名]
# 或者: from jmespath.exceptions import IncompleteExpressionError [as 别名]
def _match(self, token_type=None):
# inline'd self._current_token()
if self._current_token() == token_type:
# inline'd self._advance()
self._advance()
else:
t = self._lookahead_token(0)
lex_position = t['start']
actual_value = t['value']
actual_type = t['type']
if actual_type == 'eof':
raise exceptions.IncompleteExpressionError(
lex_position, actual_value, actual_type)
else:
message = 'Expecting: %s, got: %s' % (token_type,
actual_type)
raise exceptions.ParseError(
lex_position, actual_value, actual_type, message)
示例2: _do_parse
# 需要导入模块: from jmespath import exceptions [as 别名]
# 或者: from jmespath.exceptions import IncompleteExpressionError [as 别名]
def _do_parse(self, expression):
try:
return self._parse(expression)
except exceptions.LexerError as e:
e.expression = expression
raise
except exceptions.IncompleteExpressionError as e:
e.set_expression(expression)
raise
except exceptions.ParseError as e:
e.expression = expression
raise
示例3: _error_nud_token
# 需要导入模块: from jmespath import exceptions [as 别名]
# 或者: from jmespath.exceptions import IncompleteExpressionError [as 别名]
def _error_nud_token(self, token):
if token['type'] == 'eof':
raise exceptions.IncompleteExpressionError(
token['start'], token['value'], token['type'])
self._raise_parse_error_for_token(token, 'invalid token')
示例4: _raise_parse_error_maybe_eof
# 需要导入模块: from jmespath import exceptions [as 别名]
# 或者: from jmespath.exceptions import IncompleteExpressionError [as 别名]
def _raise_parse_error_maybe_eof(self, expected_type, token):
lex_position = token['start']
actual_value = token['value']
actual_type = token['type']
if actual_type == 'eof':
raise exceptions.IncompleteExpressionError(
lex_position, actual_value, actual_type)
message = 'Expecting: %s, got: %s' % (expected_type,
actual_type)
raise exceptions.ParseError(
lex_position, actual_value, actual_type, message)
示例5: _error_nud_token
# 需要导入模块: from jmespath import exceptions [as 别名]
# 或者: from jmespath.exceptions import IncompleteExpressionError [as 别名]
def _error_nud_token(self, token):
if token['type'] == 'eof':
raise exceptions.IncompleteExpressionError(
token['start'], token['value'], token['type'])
raise exceptions.ParseError(token['start'], token['value'],
token['type'], 'Invalid token.')
示例6: _match_multiple_tokens
# 需要导入模块: from jmespath import exceptions [as 别名]
# 或者: from jmespath.exceptions import IncompleteExpressionError [as 别名]
def _match_multiple_tokens(self, token_types):
if self._current_token() not in token_types:
t = self._lookahead_token(0)
lex_position = t['start']
actual_value = t['value']
actual_type = t['type']
if actual_type == 'eof':
raise exceptions.IncompleteExpressionError(
lex_position, actual_value, actual_type)
else:
message = 'Expecting: %s, got: %s' % (token_types,
actual_type)
raise exceptions.ParseError(
lex_position, actual_value, actual_type, message)
self._advance()