diff options
author | EuAndreh <eu@euandre.org> | 2023-09-16 18:12:18 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-09-17 11:16:42 -0300 |
commit | 8836f5e5de4afea864d10f4841eeb01f4b7364cd (patch) | |
tree | acbd66ac147d61942652c5d6b1edb22a44c5798b /squeeze.py | |
download | agahu-8836f5e5de4afea864d10f4841eeb01f4b7364cd.tar.gz agahu-8836f5e5de4afea864d10f4841eeb01f4b7364cd.tar.xz |
Add 2013-12-29 version
Changes from previous version: tweaked for portability to platforms with
16-bit int.
Diffstat (limited to 'squeeze.py')
-rw-r--r-- | squeeze.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/squeeze.py b/squeeze.py new file mode 100644 index 0000000..ce56a86 --- /dev/null +++ b/squeeze.py @@ -0,0 +1,29 @@ +import re +import sys + +output = '' + +while True: + line = sys.stdin.readline() + if not line: break + if line[0] == '#': + if output: + print output + output = '' + print line.strip() + else: + x = re.findall('\w+|\W',line) + for u in x: + if not u.isspace(): + if len(output) + len(u) > 140: + print output + output = '' + if (re.match('\w',output[-1:]) and re.match('\w',u[:1])) or (output[-1:] == '=' and u[:1] == '-'): + if len(output) + 1 + len(u) > 140: + print output + output = '' + else: + output += ' ' + output += u + +print output |