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


Python exceptions.EmptyExpressionError方法代碼示例

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


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

示例1: _initialize_for_expression

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import EmptyExpressionError [as 別名]
def _initialize_for_expression(self, expression):
        if not expression:
            raise EmptyExpressionError()
        self._position = 0
        self._expression = expression
        self._chars = list(self._expression)
        self._current = self._chars[self._position]
        self._length = len(self._expression) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:10,代碼來源:lexer.py

示例2: tokenize

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import EmptyExpressionError [as 別名]
def tokenize(self, expression):
        if not expression:
            raise EmptyExpressionError()
        previous_column = 0
        for match in self.master_regex.finditer(expression):
            value = match.group()
            start = match.start()
            end = match.end()
            if match.lastgroup == 'skip':
                # Ignore whitespace.
                previous_column = end
                continue
            if start != previous_column:
                bad_value = expression[previous_column:start]
                # Try to give a good error message.
                if bad_value == '"':
                    raise LexerError(
                        lexer_position=previous_column,
                        lexer_value=value,
                        message='Starting quote is missing the ending quote',
                        expression=expression)
                raise LexerError(lexer_position=previous_column,
                                 lexer_value=value,
                                 message='Unknown character',
                                 expression=expression)
            previous_column = end
            token_type = match.lastgroup
            handler = getattr(self, '_token_%s' % token_type.lower(), None)
            if handler is not None:
                value = handler(value, start, end)
            yield {'type': token_type, 'value': value,
                   'start': start, 'end': end}
        # At the end of the loop make sure we've consumed all the input.
        # If we haven't then we have unidentified characters.
        if end != len(expression):
            msg = "Unknown characters at the end of the expression"
            raise LexerError(lexer_position=end,
                             lexer_value='',
                             message=msg, expression=expression)
        else:
            yield {'type': 'eof', 'value': '',
                   'start': len(expression), 'end': len(expression)} 
開發者ID:TencentCloud,項目名稱:tencentcloud-cli,代碼行數:44,代碼來源:lexer.py


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