当前位置: 首页>>代码示例>>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;未经允许,请勿转载。