# HG changeset patch # User Paul Boddie # Date 1476968427 -7200 # Node ID 0fcb1351544ee1912f0db6ce5adcf57cf86a817f # Parent 4057092c9f4ac228a039194da721deea0aa2f1ef Improved output indentation. diff -r 4057092c9f4a -r 0fcb1351544e translator.py --- a/translator.py Thu Oct 20 14:46:34 2016 +0200 +++ b/translator.py Thu Oct 20 15:00:27 2016 +0200 @@ -1094,7 +1094,15 @@ return (self.indent + extra) * self.tabstop def indenttext(self, s, levels): - return s.replace("\n", "\n%s" % (levels * self.tabstop)) + lines = s.split("\n") + out = [lines[0]] + for line in lines[1:]: + out.append(levels * self.tabstop + line) + if line.endswith("("): + levels += 1 + elif line.endswith(")"): + levels -= 1 + return "\n".join(out) def writeline(self, s): print >>self.out, "%s%s" % (self.pad(), self.indenttext(s, self.indent + 1))