ref: d086e3dea41a61e2c04bbb19f698ec194b59a468
bin/wrap
#!/usr/bin/env python from textwrap import wrap import sys COLUMN_WIDTH = 79 def next_line(): l = sys.stdin.readline() if not l: sys.exit(0) return l def wrap_line(l): parts = wrap(l, COLUMN_WIDTH, break_long_words=False, break_on_hyphens=False) return '\n'.join(parts) def main(): # Skip headers l = next_line() while l.strip(): sys.stdout.write(l) l = next_line() sys.stdout.write('\n') for l in sys.stdin.readlines(): if l.startswith('>'): sys.stdout.write(l) else: sys.stdout.write(wrap_line(l)) sys.stdout.write('\n') if __name__ == '__main__': main()