本文整理汇总了Python中builder.Builder.create_model方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.create_model方法的具体用法?Python Builder.create_model怎么用?Python Builder.create_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类builder.Builder
的用法示例。
在下文中一共展示了Builder.create_model方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_module
# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import create_model [as 别名]
def add_module(self, ast, parent):
"""
Adds parsed AST to the model, without doing any optimizations. May be
called more than once, with different parsed files.
:param ast: AST of the input file, as returned by
:func:`bkl.parser.parse_file`.
"""
logger.info("processing %s", ast.filename)
submodules = []
b = Builder(on_submodule=lambda fn, pos: submodules.append((fn,pos)))
module = b.create_model(ast, parent)
while submodules:
sub_filename, sub_pos = submodules[0]
submodules.pop(0)
try:
sub_ast = parse_file(sub_filename)
except IOError as e:
if e.filename:
msg = "%s: %s" % (e.strerror, e.filename)
else:
msg = e.strerror
raise Error(msg, pos=sub_pos)
self.add_module(sub_ast, module)