6
def clear_action_codes(action_filename_list, action_begin_line, \
7
action_end_line, is_special_upgrade_code):
9
for action_filename in action_filename_list:
10
new_action_file_lines = []
11
action_file = open(action_filename, 'r')
12
action_file_lines = action_file.readlines()
13
is_action_codes = False
14
for action_file_line in action_file_lines:
15
if is_action_codes and action_file_line == (action_end_line + char_enter):
16
is_action_codes = False
17
if not is_action_codes:
18
new_action_file_lines.append(action_file_line)
19
if not is_action_codes and action_file_line == (action_begin_line + char_enter):
20
is_action_codes = True
22
new_action_file = open(action_filename, 'w')
23
for new_action_file_line in new_action_file_lines:
24
if is_special_upgrade_code:
25
if new_action_file_line == (action_end_line + char_enter):
26
new_action_file.write(' return\n')
27
new_action_file.write(new_action_file_line)
28
new_action_file.close()
30
def regenerate_upgrade_script():
31
print('\n=========run gen_upgrade_scripts.py, begin=========\n')
32
info = os.popen('./gen_upgrade_scripts.py;')
34
print('\n=========run gen_upgrade_scripts.py, end=========\n')
36
if __name__ == '__main__':
37
action_begin_line = '####========******####======== actions begin ========####******========####'
38
action_end_line = '####========******####========= actions end =========####******========####'
39
action_filename_list = \
41
'normal_ddl_actions_pre.py',\
42
'normal_ddl_actions_post.py',\
43
'normal_dml_actions_pre.py',\
44
'normal_dml_actions_post.py',\
45
'each_tenant_dml_actions_pre.py',\
46
'each_tenant_dml_actions_post.py',\
47
'each_tenant_ddl_actions_post.py'\
49
special_upgrade_filename_list = \
51
'special_upgrade_action_pre.py',\
52
'special_upgrade_action_post.py'
54
clear_action_codes(action_filename_list, action_begin_line, action_end_line, False)
55
clear_action_codes(special_upgrade_filename_list, action_begin_line, action_end_line, True)
56
regenerate_upgrade_script()