-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_syntax.py
More file actions
47 lines (38 loc) · 1.63 KB
/
Copy pathfix_syntax.py
File metadata and controls
47 lines (38 loc) · 1.63 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 os
import re
files = [
"tests/integration/ecommerce_flow_test.go",
"tests/integration/ai_agent_transaction_test.go",
"tests/integration/circuit_breaker_test.go",
"tests/integration/cross_module_compliance_test.go",
"tests/integration/stablecoin_lifecycle_test.go"
]
for file_path in files:
if not os.path.exists(file_path):
continue
with open(file_path, "r") as f:
content = f.read()
# Fix duplicated args
# Pattern: ), storeKeys[authtypes.StoreKey]... .Ctx
# We want to replace it with ).Ctx
# Simple replace since the messed up string is predictable based on my previous script
broken = ', storeKeys[authtypes.StoreKey], storetypes.NewTransientStoreKey("transient_test")).Ctx'
if broken in content:
content = content.replace(broken, ').Ctx')
# Also check if there is an extra )
# The output looked like `),), ...`
# My previous output: `...("transient_test"),\n\t), storeKeys...`
# If I replace the broken part with `.Ctx`, I get:
# `...("transient_test"),\n\t).Ctx`
# This looks correct:
# s.ctx = testutil.DefaultContextWithDB(...
# storetypes.NewTransientStoreKey("transient_test"),
# ).Ctx
# Let's try replacing the specific string I see in the file read output.
# `), storeKeys[authtypes.StoreKey], storetypes.NewTransientStoreKey("transient_test")).Ctx.`
# Wait, the output has `).Ctx.` ending with dot?
# No, `.Ctx.\n\t\tWithBlockHeight`
content = content.replace(broken, ').Ctx')
with open(file_path, "w") as f:
f.write(content)
print(f"Updated {file_path}")