-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
fix_async.py
35 lines (28 loc) · 1.02 KB
/
fix_async.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
import os
basedir = "."
folders = os.listdir(basedir)
for folder in folders:
try:
subfolders = os.listdir(f"{basedir}/{folder}")
except:
continue
for subfolder in subfolders:
filename = f"{basedir}/{folder}/{subfolder}/src/app.py"
data = ""
try:
with open(f"{filename}", "r") as tmp:
data = tmp.read()
data = data.replace("async def", "def", -1)
data = data.replace("await ", "", -1)
data = data.replace("asyncio.run(", "", -1)
data = data.replace(", debug=True)", "", -1)
data = data.replace(", debug=False)", "", -1)
data = data.replace(",debug=True)", "", -1)
data = data.replace(",debug=False)", "", -1)
if len(data) > 0:
with open(f"{filename}", "w+") as tmp:
tmp.write(data)
print("Fixed: %s" % filename)
except:
print("Skipped: %s" % filename)
#break