本文整理汇总了Python中pyparsing.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python pyparsing.__version__方法的具体用法?Python pyparsing.__version__怎么用?Python pyparsing.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing
的用法示例。
在下文中一共展示了pyparsing.__version__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_dot_data
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import __version__ [as 别名]
def parse_dot_data(data):
global top_graphs
top_graphs = list()
if PY3:
if isinstance(data, bytes):
# this is extremely hackish
try:
idx = data.index(b'charset') + 7
while data[idx] in b' \t\n\r=':
idx += 1
fst = idx
while data[idx] not in b' \t\n\r];,':
idx += 1
charset = data[fst:idx].strip(b'"\'').decode('ascii')
data = data.decode(charset)
except:
data = data.decode('utf-8')
else:
if data.startswith(codecs.BOM_UTF8):
data = data.decode('utf-8')
try:
graphparser = graph_definition()
if pyparsing_version >= '1.2':
graphparser.parseWithTabs()
tokens = graphparser.parseString(data)
if len(tokens) == 1:
return tokens[0]
else:
return [g for g in tokens]
except ParseException:
err = sys.exc_info()[1]
print(err.line)
print(" " * (err.column - 1) + "^")
print(err)
return None
示例2: parse_dot_data
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import __version__ [as 别名]
def parse_dot_data(data):
global top_graphs
top_graphs = list()
if PY3:
if isinstance(data, bytes):
# this is extremely hackish
try:
idx = data.index(b'charset') + 7
while data[idx] in b' \t\n\r=':
idx += 1
fst = idx
while data[idx] not in b' \t\n\r];,':
idx += 1
charset = data[fst:idx].strip(b'"\'').decode('ascii')
data = data.decode(charset)
except Exception:
data = data.decode('utf-8')
else:
if data.startswith(codecs.BOM_UTF8):
data = data.decode('utf-8')
try:
graphparser = graph_definition()
if pyparsing.__version__ >= '1.2':
graphparser.parseWithTabs()
tokens = graphparser.parseString(data)
if len(tokens) == 1:
return tokens[0]
else:
return [g for g in tokens]
except pyparsing.ParseException:
err = sys.exc_info()[1]
print(err.line)
print(" " * (err.column - 1) + "^")
print(err)
return None