-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.py
51 lines (40 loc) · 1.08 KB
/
manifest.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
#!user/bin/env python
# -*- coding: utf-8 -*-
import os
import json
import hashlib
#资源清单生成
dic = {
"assets": {},
"engineVersion": "3.6",
"packageUrl": "http://",
"remoteManifestUrl": "http://xx/project.manifest",
"remoteVersionUrl": "http://xx/version.manifest",
"searchPaths": [],
"version": "0.1.9.3020"
}
assets ={}
def md5Fils(path):
path = path.replace("\\","/")
if not os.path.isdir(path) and not os.path.isfile(path):
return false
if os.path.isfile(path):
with open(path,"r") as curFile:
fileStr = curFile.read()
m = hashlib.md5()
m.update(fileStr)
md5Str = str(m.hexdigest())
d = dict(md5 = md5Str)
key = path[len(os.getcwd())+1:-1]
assets[key] = d
elif os.path.isdir(path):
for f in os.listdir(path):
md5Fils(os.path.join(path,f))
def main():
md5Fils(os.path.join(os.getcwd(),"res"))
md5Fils(os.path.join(os.getcwd(),"src"))
dic["assets"] = assets
with open("project.manifest","w") as manifest:
manifest.write(json.dumps(dic,indent=1))
if __name__ == '__main__':
main()