当前位置: 首页>>代码示例>>Python>>正文


Python Database.register_format方法代码示例

本文整理汇总了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)
开发者ID:hastelloy,项目名称:pycalphad,代码行数:32,代码来源:tdb.py


注:本文中的pycalphad.Database.register_format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。