delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kioslave / fish / generate_fishcode.py
blobac28f46bc30fd70b6973b2bd992425f11d6f3c33
1 #1 is generate_fishcode.py
2 #2 is md5sum
3 #3 is the output file
4 #4 are the parameters for cut
5 import sys
6 import re
7 import hashlib
9 fp = open(sys.argv[1], "rb")
10 r = fp.read()
11 fp.close()
13 m = hashlib.md5()
14 m.update(r)
15 sm = m.hexdigest()
17 fp = open(sys.argv[1], "r")
18 r = fp.read()
19 fp.close()
21 fp = open(sys.argv[2], "wb")
22 fp.write('#define CHECKSUM "%s"\n' % sm)
23 fp.write('static const char *fishCode(\n')
25 r = re.sub(r'\\', r'\\\\', r)
26 r = re.sub(r'"', r'\\"', r)
27 p = re.compile('^[ ]*', re.M)
28 r = p.sub('"', r)
29 p = re.compile(r'^"# .*\n*', re.M)
30 r = p.sub('', r)
31 p = re.compile('[ ]*$', re.M)
32 r = p.sub(r'\\n"', r)
33 p = re.compile(r'^"\\n"\n?', re.M)
34 r = p.sub('', r)
35 r = re.sub(r'{CHECKSUM}', sm, r, 1)
36 fp.write(r + ");\n")
37 fp.close()