forked from swccgpc/holotable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_bullets.py
executable file
·38 lines (27 loc) · 914 Bytes
/
fix_bullets.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
36
37
38
#!/usr/bin/env python3
import codecs
def fix_cdf_file_bullets(cdf_filename):
print("Fixing Bullets in "+cdf_filename)
proper_bullet = b'\x95'.decode('cp1252')
print(" * Reading CDF File")
fh = codecs.open(cdf_filename, "rb", 'cp1252')
txt = fh.read()
fh.close
print(" * Read Contents: "+str(type(txt)))
print(" * Replacing known bad/invalid bullets")
txt = txt.replace("�", proper_bullet)
txt = txt.replace("½", proper_bullet)
txt = txt.replace("¿", proper_bullet)
txt = txt.replace("ï", proper_bullet)
#for lin in txt.split("\n"):
# if "Death Star: War Room" in lin:
# print(lin[0:70])
# if "Vader's Lightsaber" in lin:
# print(lin[0:70])
print(" * Writing CDF File")
fh = codecs.open(cdf_filename, "w", 'cp1252')
fh.write(txt)
fh.close
print(" * done.\n")
fix_cdf_file_bullets("darkside.cdf")
fix_cdf_file_bullets("lightside.cdf")