本文整理匯總了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]))
示例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]
示例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
示例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))
示例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)