本文整理匯總了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