提交 33ae1331 编写于 作者: F fengjiayi

refine indent

上级 5a3b06be
......@@ -14,6 +14,7 @@
import collections
import contextlib
import re
import numpy as np
......@@ -643,14 +644,15 @@ class Block(object):
assert isinstance(throw_on_error, bool) and isinstance(with_details,
bool)
if with_details:
re_add_indent = re.compile(r"\n(.)")
res_str = "blocks {\n idx: %d\n parent_idx: %d" % (
self.idx, self.parent_idx)
for var in self.vars.itervalues():
res_str += "\n vars {\n %s }" % var.to_string(
throw_on_error).replace("\n", "\n ")
res_str += "\n vars {\n %s }" % re_add_indent.sub(
r"\n \1", var.to_string(throw_on_error))
for op in self.ops:
res_str += "\n ops {\n %s }" % op.to_string(
throw_on_error).replace("\n", "\n ")
res_str += "\n ops {\n %s }" % re_add_indent.sub(
r"\n \1", op.to_string(throw_on_error))
res_str += "\n}"
else:
protostr = self.desc.serialize_to_string()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册