-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchange_core_async.py
More file actions
59 lines (44 loc) · 1.91 KB
/
Copy pathchange_core_async.py
File metadata and controls
59 lines (44 loc) · 1.91 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
48
49
50
51
52
53
54
55
56
57
58
59
import json
import glob
import shutil
import os
import subprocess
def main() :
for filename in glob.iglob("/pyter/benchmark/core-8065/**/*.py", recursive=True) :
if filename == "/pyter/benchmark/core-8065/homeassistant/util/async.py" :
with open(filename, 'r') as f :
lines = f.readlines()
for i, line in enumerate(lines) :
if "from asyncio import async" in line :
lines[i] = line.replace("from asyncio import async", "")
if "ensure_future = async" in line :
lines[i] = line.replace("ensure_future = async", "pass")
with open(filename+"_new", 'w') as f :
for line in lines :
f.write(line)
os.rename(filename, filename+"_old")
os.rename(filename+"_new", "/pyter/benchmark/core-8065/homeassistant/util/core_async.py")
continue
change = False
with open(filename, 'r') as f :
lines = f.readlines()
for i, line in enumerate(lines) :
if "homeassistant.util.async" in line :
lines[i] = line.replace("homeassistant.util.async", "homeassistant.util.core_async")
change = True
break
if "..util.async" in line :
lines[i] = line.replace(" ..util.async ", " ..util.core_async ")
change = True
break
if ".async" in line :
lines[i] = line.replace(" .async ", " .core_async ")
change = True
break
if change :
with open(filename+"_new", 'w') as f :
for line in lines :
f.write(line)
os.rename(filename, filename+"_old")
os.rename(filename+"_new", filename)
main()