[667a13]: generate / run / make0.py Maximize Restore History

Download this file

make0.py    56 lines (46 with data), 1.0 kB

 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
from __future__ import print_function
import sys
import re
import string
cs1=r'Sense.create=(.*)casedwordid([^,]*)'
cs2=r'Sense.create=\1casedwordid\2 NULL'
c1=r' DEFAULT CHARSET=utf8'
c2=r''
h1=r'\sUSING HASH'
h2=r''
q1=r'`'
q2=r''
def outputdata(data):
print("%s" % (data))
return
def replace(s1,s2,line):
line2=re.sub(s1,s2,line)
if re.search(s1,line):
#print("matches [%s] %s" % (s1,line), file=sys.stderr)
pass
if line != line2:
#print(line, file=sys.stderr)
#print(line2, file=sys.stderr)
#exit()
pass
return line2
ref=sys.argv[1]
f2 = open(ref, 'r+')
lines2=f2.readlines()
f2.close()
#print("DIFF", file=sys.stderr)
lines=sys.__stdin__.readlines()
for i in range(len(lines)):
line=lines[i].strip()
line2=lines2[i].strip()
#print(line, file=sys.stderr)
if re.match("^.*=CREATE TABLE.*$", line):
line=line2
line=replace(c1,c2,line)
line=replace(cs1,cs2,line)
line=replace(q1,q2,line)
line=replace(h1,h2,line)
if re.match("^.*GROUP_CONCAT.*$", line2):
line=line2
outputdata(line)