forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (37 loc) · 1.25 KB
/
main.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
36
37
38
39
40
41
42
43
44
import os
def get_files(path):
for item in os.listdir(path):
dir_file = os.path.join(path, item)
if os.path.isfile(dir_file):
yield dir_file
else:
for xx in get_files(dir_file):
yield xx
main_set = set()
for file in get_files('.'):
if file.endswith('py'):
continue
try:
flag = False
# data = ''
# with open(file,'r', encoding='utf8')as f:
# data = f.read()
# if 'clientv3' in data and 'clientv3 "github.com/ls-2018/etcd_cn/client_sdk/v3"' not in data:
# data = data.replace('import (', 'import (\n clientv3 "github.com/ls-2018/etcd_cn/client_sdk/v3"')
# flag = True
#
# # print(file)
# if flag:
# with open(file, 'w', encoding='utf8', )as f:
# f.write(data)
with open(file, 'r', encoding='utf8') as f:
if 'package main' in f.read():
main_set.add(os.path.dirname(file))
except Exception:
pass
for item in main_set:
# print(item)
print('cd %s ; go build . ; cd -' % item.replace('\\', '/'))
for item in main_set:
# print(item)
print('rm %s' % os.path.join(item, item.split('/')[-1]))