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


Python exceptions.LexerError方法代碼示例

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


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

示例1: _consume_until

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [as 別名]
def _consume_until(self, delimiter):
        # Consume until the delimiter is reached,
        # allowing for the delimiter to be escaped with "\".
        start = self._position
        buff = ''
        self._next()
        while self._current != delimiter:
            if self._current == '\\':
                buff += '\\'
                self._next()
            if self._current is None:
                raise LexerError(lexer_position=start,
                                 lexer_value=self._expression,
                                 message="Unclosed %s delimiter" % delimiter)
            buff += self._current
            self._next()
        # Skip the closing delimiter.
        self._next()
        return buff 
開發者ID:skarlekar,項目名稱:faces,代碼行數:21,代碼來源:lexer.py

示例2: _consume_literal

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [as 別名]
def _consume_literal(self):
        start = self._position
        lexeme = self._consume_until('`').replace('\\`', '`')
        try:
            # Assume it is valid JSON and attempt to parse.
            parsed_json = loads(lexeme)
        except ValueError:
            try:
                # Invalid JSON values should be converted to quoted
                # JSON strings during the JEP-12 deprecation period.
                parsed_json = loads('"%s"' % lexeme.lstrip())
                warnings.warn("deprecated string literal syntax",
                              PendingDeprecationWarning)
            except ValueError:
                raise LexerError(lexer_position=start,
                                 lexer_value=self._expression,
                                 message="Bad token %s" % lexeme)
        token_len = self._position - start
        return {'type': 'literal', 'value': parsed_json,
                'start': start, 'end': token_len} 
開發者ID:skarlekar,項目名稱:faces,代碼行數:22,代碼來源:lexer.py

示例3: _consume_until

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [as 別名]
def _consume_until(self, delimiter):
        # Consume until the delimiter is reached,
        # allowing for the delimiter to be escaped with "\".
        start = self._position
        buff = ''
        self._next()
        while self._current != delimiter:
            if self._current == '\\':
                buff += '\\'
                self._next()
            if self._current is None:
                # We're at the EOF.
                raise LexerError(lexer_position=start,
                                 lexer_value=self._expression[start:],
                                 message="Unclosed %s delimiter" % delimiter)
            buff += self._current
            self._next()
        # Skip the closing delimiter.
        self._next()
        return buff 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:22,代碼來源:lexer.py

示例4: _consume_literal

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [as 別名]
def _consume_literal(self):
        start = self._position
        lexeme = self._consume_until('`').replace('\\`', '`')
        try:
            # Assume it is valid JSON and attempt to parse.
            parsed_json = loads(lexeme)
        except ValueError:
            try:
                # Invalid JSON values should be converted to quoted
                # JSON strings during the JEP-12 deprecation period.
                parsed_json = loads('"%s"' % lexeme.lstrip())
                warnings.warn("deprecated string literal syntax",
                              PendingDeprecationWarning)
            except ValueError:
                raise LexerError(lexer_position=start,
                                 lexer_value=self._expression[start:],
                                 message="Bad token %s" % lexeme)
        token_len = self._position - start
        return {'type': 'literal', 'value': parsed_json,
                'start': start, 'end': token_len} 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:22,代碼來源:lexer.py

示例5: _consume_quoted_identifier

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [as 別名]
def _consume_quoted_identifier(self):
        start = self._position
        lexeme = '"' + self._consume_until('"') + '"'
        try:
            token_len = self._position - start
            return {'type': 'quoted_identifier', 'value': loads(lexeme),
                    'start': start, 'end': token_len}
        except ValueError as e:
            error_message = str(e).split(':')[0]
            raise LexerError(lexer_position=start,
                             lexer_value=lexeme,
                             message=error_message) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:14,代碼來源:lexer.py

示例6: _do_parse

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [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 
開發者ID:skarlekar,項目名稱:faces,代碼行數:14,代碼來源:parser.py

示例7: _token_quoted_identifier

# 需要導入模塊: from jmespath import exceptions [as 別名]
# 或者: from jmespath.exceptions import LexerError [as 別名]
def _token_quoted_identifier(self, value, start, end):
        try:
            return loads(value)
        except ValueError as e:
            error_message = str(e).split(':')[0]
            raise LexerError(lexer_position=start,
                             lexer_value=value,
                             message=error_message) 
開發者ID:TencentCloud,項目名稱:tencentcloud-cli,代碼行數:10,代碼來源:lexer.py


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