当前位置: 首页>>代码示例>>Python>>正文


Python pyparsing.ParseBaseException方法代码示例

本文整理汇总了Python中pyparsing.ParseBaseException方法的典型用法代码示例。如果您正苦于以下问题:Python pyparsing.ParseBaseException方法的具体用法?Python pyparsing.ParseBaseException怎么用?Python pyparsing.ParseBaseException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyparsing的用法示例。


在下文中一共展示了pyparsing.ParseBaseException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __query

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import ParseBaseException [as 别名]
def __query(self, path):
        # replace aliases
        path = self.__substAlias(path)

        while path.endswith('/'): path = path[:-1]
        if path:
            try:
                path = self.__pathGrammer.parseString(path, True)
            except pyparsing.ParseBaseException as e:
                raise BobError("Invalid syntax: " + str(e),
                               help=markLocation(e.line, e.col))
            assert len(path) == 1
            assert isinstance(path[0], LocationPath)
            #print(path[0])
            return path[0].evalForward(self.__getGraphRoot())
        else:
            root = self.__getGraphRoot()
            return (set([root]), set([root])) 
开发者ID:BobBuildTool,项目名称:bob,代码行数:20,代码来源:pathspec.py

示例2: parseExpression

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import ParseBaseException [as 别名]
def parseExpression(self, expression):
        try:
            ret = self.__ifgrammer.parseString(expression, True)
        except pyparsing.ParseBaseException as e:
            raise ParseError("Invalid syntax: " + str(e))
        return ret[0] 
开发者ID:BobBuildTool,项目名称:bob,代码行数:8,代码来源:stringparser.py

示例3: search

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import ParseBaseException [as 别名]
def search(self, search_base=None, search_scope=None,
               search_filter=None, attributes=None, paged_size=5,
               size_limit=0, paged_cookie=None):
        s_filter = list()
        candidates = list()
        self.response = list()
        self.result = dict()

        try:
            if isinstance(search_filter, bytes):
                # We need to convert to unicode otherwise pyparsing will not
                # find the u"ö"
                search_filter = to_unicode(search_filter)
            expr = Connection._parse_filter()
            s_filter = expr.parseString(search_filter).asList()[0]
        except pyparsing.ParseBaseException as exx:
            # Just for debugging purposes
            s = "{!s}".format(exx)

        for item in s_filter:
            if item[0] in self.operation:
                candidates = self.operation.get(item[0])(search_base,
                                                         s_filter)
        self.response = Connection._deDuplicate(candidates)

        return True 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:28,代码来源:ldap3mock.py

示例4: test_fail_parse_forbidden_characters

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import ParseBaseException [as 别名]
def test_fail_parse_forbidden_characters(self, forbidden_char):
        with pytest.raises(ParseBaseException):
            ConfigFactory.parse_string('a: hey man{}'.format(forbidden_char)) 
开发者ID:chimpler,项目名称:pyhocon,代码行数:5,代码来源:test_config_parser.py

示例5: _text_to_config_dict

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import ParseBaseException [as 别名]
def _text_to_config_dict(text):
        if not isinstance(text, six.string_types):
            raise ValueError("Model configuration parsing only supports string")
        try:
            return ConfigFactory.parse_string(text).as_plain_ordered_dict()
        except pyparsing.ParseBaseException as ex:
            pos = "at char {}, line:{}, col:{}".format(ex.loc, ex.lineno, ex.column)
            six.raise_from(ValueError("Could not parse configuration text ({}):\n{}".format(pos, text)), None)
        except Exception:
            six.raise_from(ValueError("Could not parse configuration text:\n{}".format(text)), None) 
开发者ID:allegroai,项目名称:trains,代码行数:12,代码来源:model.py


注:本文中的pyparsing.ParseBaseException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。