groovy_formatter.py #1

  • //
  • guest/
  • karl_wirth/
  • example_scripts/
  • groovy_formatter.py
  • View
  • Commits
  • Open Download .zip Download (648 B)
# 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)

# Change User Description Committed
#1 21509 Karl Wirth Simple example Groovy formatter for formatting Jenkins snippets.
Expects data passed through stdin. Outputs results to stdout.