-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathre_name.py
110 lines (92 loc) · 3.63 KB
/
re_name.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# coding=utf-8
import os
import re
import ui_MAIN_UI
class App(object):
def __init__(self):
# 初始化对应关系
self.correspondence = {}
self.correspondence_ground = {}
# 文件夹所在位置
self.app_path = ""
self.ground_path = ""
def traverse_app(self, path):
file_list = os.walk(path)
# 开始遍历文件夹
for dir_path, dir_name, file_name in file_list:
# 显示文件夹内的所有文件名
for file_name_in in file_name:
if file_name_in == "":
app = parse_app(os.path.join(dir_path, ""))
self.correspondence[app] = dir_path
print(self.correspondence)
self.rename_app()
def rename_app(self):
# key在前,value在后
for new_name, dir_name in self.correspondence.items():
os.renames(dir_name, os.path.join(self.app_path, new_name))
def traverse_ground(self, path):
file_list = os.walk(path)
# 开始遍历文件夹
for dir_path, dir_name, file_name in file_list:
# 显示文件夹内的所有文件名
for file_name_in in file_name:
if file_name_in == "":
ground = parse_ground(os.path.join(dir_path, ""))
self.correspondence_ground[ground] = dir_path
print(self.correspondence_ground)
self.rename_ground()
def rename_ground(self):
# key在前,value在后
for new_name, dir_name in self.correspondence_ground.items():
os.renames(dir_name, os.path.join(self.ground_path, new_name))
def parse_app(file_name):
with open(file_name, "rb") as f: # 注意这里要是rb,不然gbk读不出来
for line in f:
# 想想能不能提供接口日后来增加其他配置项
if re.search(b'', line.strip()):
return""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
def parse_ground(file_name):
with open(file_name, "rb") as f: # 注意这里要是rb,不然gbk读不出来
for line in f:
# 想想能不能提供接口日后来增加其他配置项
if re.search(b'', line.strip()):
return""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
elif re.search(b'', line.strip()):
return ""
App().traverse_app(r"")
# App().traverse_ground(r"")