Managing Google Groups headaches

rusi rustompmody at gmail.com
Thu Nov 28 13:13:36 EST 2013


Here's a 1-click pure python solution.

As I said I dont know how to manage errors!

1. Put it in a file say cleangg.py and make it executable
2. Install it as the 'editor' for the "Its all text" firefox addon
3. Click the edit and you should get a cleaned out post

------------------------------
#!/usr/bin/env python3

from sys import argv
import re
from re import sub

def clean(s):
    s1 = sub("^> *\n> *$", "¶",   s,  flags=re.M)
    s2 = sub("^> *\n",     "",    s1, flags=re.M)
    s3 = sub("¶\n",        ">\n", s2, flags=re.M)
    return s3

def main():
    print ("argv[1] %s" % argv[1])
    with open(argv[1]) as f:
        s = f.read()
    with open(argv[1], "w") as f:
        f.write(clean(s))

main()



More information about the Python-list mailing list