Add script indent_begin_end.py to make logs more readable.
This commit is contained in:
15
indent_begin_end.py
Executable file
15
indent_begin_end.py
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
indent = b""
|
||||||
|
|
||||||
|
with open(sys.argv[1], 'rb') as fin:
|
||||||
|
with open(sys.argv[2], 'wb') as fout:
|
||||||
|
for line in fin:
|
||||||
|
if line.endswith(b"end\r\n"):
|
||||||
|
indent = indent[:-2]
|
||||||
|
fout.write(indent)
|
||||||
|
fout.write(line)
|
||||||
|
if line.endswith(b"begin\r\n"):
|
||||||
|
indent = indent + b" "
|
Reference in New Issue
Block a user