-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbold_cleanup.py
35 lines (28 loc) · 985 Bytes
/
bold_cleanup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/local/bin/python
import argparse
import os
import os.path
import shutil
from sys import argv, exit
def get_correctedFiles(path):
for f in os.listdir(path):
print "removing bold and italic markup in file %s" % f
infile = open(os.path.join(path, f)).read()
infile = infile.replace("**","")
infile = infile.replace(" _","")
infile = infile.replace("_ ","")
infile = infile.replace(" __ ","")
outfile = open(os.path.join(path, f), "w")
outfile.write(infile)
outfile.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="removes all bad bold and italic markup")
parser.add_argument("path", help="folder containing html (raw) files")
args = parser.parse_args()
if not os.path.exists(args.path):
stderr.write("folder %s not found." % args.path)
exit()
if get_correctedFiles(args.path):
print "Error"
else:
print "Done"