acme/bin/t2s
2017-08-17 01:04:01 +03:00

26 lines
433 B
Python
Executable file

#!/usr/bin/env python3
import sys
DEFAULT_N_SPACES = 4
TAB, SPACE = ' ', ' '
try:
n_spaces = int(sys.argv[1])
except:
n_spaces = DEFAULT_N_SPACES
if n_spaces < 1:
n_spaces = DEFAULT_N_SPACES
for line in sys.stdin:
line = line.rstrip()
n_tabs = 0
for ch in line:
if ch != TAB:
break
n_tabs += 1
spaces = SPACE * n_spaces * n_tabs
print(spaces, line[n_tabs:], sep='')