本文整理匯總了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()