本文整理汇总了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)