-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathob_recoverydelete.py
44 lines (40 loc) · 1.22 KB
/
ob_recoverydelete.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
39
40
41
42
43
44
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import json
import sys
def main():
if len(sys.argv) != 2:
raise ValueError("invalid~~~")
clog_dump_file = sys.argv[1]
re_p = re.compile(r'OLD_ROW=\{(.*?)\} \|')
re_p_0 = re.compile(r'([0-9]+):\{(.*?)\}')
re_p_1 = re.compile(r', .*$')
re_p_2 = re.compile(r'".*?":(.*?)$')
row_lst = []
with open(clog_dump_file, 'r') as f:
for i in f:
row_lst.append(i.strip())
for line in row_lst:
re_res = re_p.findall(line)
for jj in re_res:
if jj.strip() == '{}': continue
r_str = jj.strip()
re_jj = re_p_0.findall(r_str)
is_one = True
is_in = False
for jjj in re_jj:
if not is_one:
print(", ", end="")
else:
print("(", end="")
is_one = False
data = re_p_1.sub("", jjj[1]).strip()
data = re_p_2.search(data)
data = data.group(1)
print(data, end="")
is_in = True
if is_in:
print(");")
if __name__ == "__main__":
main()