-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGIF.py
More file actions
60 lines (47 loc) · 1.93 KB
/
GIF.py
File metadata and controls
60 lines (47 loc) · 1.93 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
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-03-27 19:18:37
# @Author : 袁平华 (yuanpinghua@yeah.net)
# @Link : yuanph.org
# @Version : 1.0
"""将文件夹下面的GIF动图转成plist文件
"""
import os
import shutil
from biplist import *
def findFileListWithsubfix(subfix, path):
# 分别返回:父目录,所有文件夹,所有文件
result = []
index = 1
for root, parent, files in os.walk(path):
subindex=1
package = {}
item = []
for file in files:
if os.path.splitext(file)[1] == subfix:
newname = "%zd_%zd.gif"%(index,subindex)
itemdic = {"id": '%d' % index, "imageGIF": newname, "text": os.path.splitext(file)[0], "type": 1,"key":"custom_emoji/%s"%(newname)}
item.append(itemdic)
sourcefile = os.path.join(root, file)
moveFileAndRename(sourcefile,os.path.basename(root).splitext(' ')[1],)
subindex+=1
else:
if os.path.splitext(file)[1] == '.pdf':
print("%s " % os.path.basename(root))
packageDes = {"packageName": os.path.basename(
root), "packageImage": os.path.splitext(file)[0], "type": 1}
package.update({"package": packageDes})
if len(item) > 0:
index += 1
package.update({"items": item})
result.append(package)
# writePlist(package, './emoji/'+ os.path.basename(root)+".plist")
# result.append(package)
writePlist(result, "builtin_GIF.plist")
return result
def moveFileAndRename(sourcefile, detinationFile='', newName=''):
print("fdasf"+detinationFile)
shutil.move(sourcefile, '/Users/yuanpinghua/Desktop/emoji/%s.gif'%(detinationFile))
if __name__ == '__main__':
result = findFileListWithsubfix(
'.gif', '/Users/yuanpinghua/Desktop/new Project/GIFEmoji')