本文整理汇总了Python中pycalphad.Database.register_format方法的典型用法代码示例。如果您正苦于以下问题:Python Database.register_format方法的具体用法?Python Database.register_format怎么用?Python Database.register_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalphad.Database
的用法示例。
在下文中一共展示了Database.register_format方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from pycalphad import Database [as 别名]
# 或者: from pycalphad.Database import register_format [as 别名]
# Remove extra whitespace inside line
splitlines = [' '.join(k.split()) for k in splitlines]
# Remove comments
splitlines = [k.strip().split('$', 1)[0] for k in splitlines]
# Combine everything back together
lines = ' '.join(splitlines)
# Now split by the command delimeter
commands = lines.split('!')
# Filter out comments one more time
# It's possible they were at the end of a command
commands = [k.strip() for k in commands if not k.startswith("$")]
# Temporary storage while we process type definitions
dbf.tdbtypedefs = {}
for command in commands:
if len(command) == 0:
continue
tokens = None
try:
tokens = _tdb_grammar().parseString(command)
_TDB_PROCESSOR[tokens[0]](dbf, *tokens[1:])
except ParseException:
print("Failed while parsing: " + command)
print("Tokens: " + str(tokens))
raise
del dbf.tdbtypedefs
Database.register_format("tdb", read=read_tdb, write=write_tdb)