本文整理汇总了Python中interpreter.Interpreter.run_agenda方法的典型用法代码示例。如果您正苦于以下问题:Python Interpreter.run_agenda方法的具体用法?Python Interpreter.run_agenda怎么用?Python Interpreter.run_agenda使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interpreter.Interpreter
的用法示例。
在下文中一共展示了Interpreter.run_agenda方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import run_agenda [as 别名]
def main():
parser = argparse.ArgumentParser(description="The dyna interpreter!")
parser.add_argument("--version", action="store_true", help="Print version information.")
parser.add_argument("source", nargs="*", type=path, help="Path to Dyna source file.")
parser.add_argument("-i", dest="interactive", action="store_true", help="Fire-up REPL after runing solver..")
parser.add_argument("-o", "--output", dest="output", type=argparse.FileType("wb"), help="Write solution to file.")
parser.add_argument("--post-process", nargs="*", help="run post-processor.")
parser.add_argument("--load", nargs="*", help="run loaders.")
parser.add_argument("--debug", action="store_true", help="Debug planner, normalizer and parser.")
args = parser.parse_args()
if args.version:
try:
print (dynahome / "dist/VERSION").text() # XREF:VERSION
except IOError:
print "failed to obtain version info."
exit(0)
interp = Interpreter()
crash_handler()
if args.source:
if len(args.source) > 1:
# concatenate files
with file(interp.compiler.tmp / "tmp.dyna", "wb") as g:
for f in args.source:
if not f.exists():
print "File `%s` does not exist." % f
return
with file(f) as f:
g.write("\n")
g.write("%" * 80)
g.write("\n")
g.write("%% ")
g.write(f.name)
g.write("\n")
g.write(f.read())
args.source = g.name
else:
[args.source] = args.source
if not args.source.exists():
print "File `%s` does not exist." % args.source
return
if args.debug:
import debug
debug.main(args.source, browser=True)
exit(1)
try:
plan = interp.dynac(args.source)
except DynaCompilerError as e:
print e
exit(1)
interp.load_plan(plan)
interp.run_agenda()
if args.load:
for cmd in args.load:
load.run(interp, cmd)
if args.post_process:
for cmd in args.post_process:
post.run(interp, cmd)
if args.load or args.post_process or args.source:
interp.dump_charts(args.output) # should be a post-processor
if args.interactive or not args.source:
repl = REPL(interp)
def repl_crash():
# all files the interpreter generated
with file(dotdynadir / "crash-repl.log", "wb") as f:
for line in repl.lines:
print >> f, line
crash_handler.hooks.append(repl_crash)
repl.cmdloop()