# Simple example Groovy formatter for formatting Jenkins snippets # Expects data passed through stdin. Outputs results to stdout. import sys def pTABS(t): sys.stdout.write("\t"*t); TABS=1 for line in sys.stdin: for c in line: if c == "]": sys.stdout.write("\n") pTABS(TABS) sys.stdout.write("]") TABS = TABS - 1 elif c == "[": sys.stdout.write("\n") TABS = TABS + 1 pTABS(TABS) sys.stdout.write("[\n") pTABS(TABS) sys.stdout.write(" ") elif c == ",": sys.stdout.write(",\n") pTABS(TABS) else: sys.stdout.write(c)