當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。