-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_methods.py
More file actions
47 lines (38 loc) · 1.25 KB
/
Copy pathdelete_methods.py
File metadata and controls
47 lines (38 loc) · 1.25 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
import re
file_path = "/home/philip/githome/teaql-java/teaql-sql/src/main/java/io/teaql/core/sql/SQLRepository.java"
with open(file_path, "r") as f:
lines = f.readlines()
methods_to_remove = [
"collectDataTables",
"tableAlias",
"joinTables",
"collectSelectSql",
"prepareOrderBy",
"prepareCondition",
"collectAggregationSelectSql",
"collectAggregationGroupBySql",
"collectAggregationTables"
]
for method in methods_to_remove:
# find line with method signature
start_line = -1
for i, line in enumerate(lines):
if method + "(" in line and ("public" in line or "protected" in line or "private" in line):
start_line = i
break
if start_line == -1:
continue
# find open brace
brace_count = 0
in_method = False
end_line = -1
for i in range(start_line, len(lines)):
brace_count += lines[i].count('{')
brace_count -= lines[i].count('}')
if lines[i].count('{') > 0:
in_method = True
if in_method and brace_count == 0:
end_line = i
break
if start_line != -1 and end_line != -1:
print(f"sed -i '{start_line+1},{end_line+1}d' {file_path}")