-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrenameIcon.py
65 lines (58 loc) · 1.88 KB
/
renameIcon.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
#!/user/local/bin/python
# -*- coding:utf-8 -*-
import os
import sys
import zipfile
import time
import fileinput
import chardet
import codecs
import shutil
error_icon_file_list = ''
def getFileNameList():
fileNameList = {}
filePath = os.path.join(os.getcwd(),"orgin_icon_file","icon_rename_file.conf")
file = codecs.open(filePath,'r','utf-8')
text = file.read()
file.close()
#print text
for line in text.split("\n"):
#print "%s%s" %(line , "---")
if not line:
continue
if line == '':
continue
if line.startswith("#"):
continue
line = line.strip()
array = line.split("=")
fileNameList[array[0]] = array[1]
return fileNameList
def tranName(fileNameList):
global error_icon_file_list
print "changing list :"
for item in fileNameList:
pass
#print u"orginName:%s ===>tansName:%s" % (item ,fileNameList[item])
for item in fileNameList:
try:
print item.encode('gbk')
shutil.copyfile(os.path.join( os.getcwd(),"orgin_icon_file", item.encode('gbk') ),os.path.join( os.getcwd(),"trans_name_file",fileNameList[item] ) )
except Exception , e :
print "error , "
print e
error_icon_file_list += u"转换失败,原始文件:" + item+ u"\t\t\t,转换后文件:" + fileNameList[item]+ "\r\n\r\n"
continue;
# 输出错误列表
filePath = os.path.join(os.getcwd(),"orgin_icon_file","error_list.txt")
file = codecs.open(filePath,'w','utf-8')
if error_icon_file_list == '':
error_icon_file_list = u'没有错误 ,请查看 trans_name_file 文件夹并使用图标 '
file.write(error_icon_file_list)
file.close()
print u"转换成功 ,可能有部分图片转换失败 ,请查看orgin_icon_file 是否有 error_list.txt 文件 ,转换错误的信息将写在此文件中 ,"
#start
configFileList = getFileNameList()
# print configFileList
# 更换下列文件
tranName(configFileList)