-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.py
executable file
·77 lines (71 loc) · 2.92 KB
/
bundle.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
#!/usr/bin/env python
from wrpg.piaf import pack
from wrpg.piaf.common import FileType, CompressionType, PIAF_VERSION
minimal_data = {"version": PIAF_VERSION,
"file_entries": [
{
"path": "data/core/press.png",
"file_name": "t_dbgfnt",
"compression_type": CompressionType.RAW,
"file_type": FileType.TEXTURE
},
{
"path": "data/core/press",
"file_name": "f_dbgfnt",
"compression_type": CompressionType.RAW,
"file_type": FileType.UNKNOWN
}
]
}
wip_wrpg_data = {"version": PIAF_VERSION,
"file_entries": [
{
"path": "data/wip_data/overworld.png",
"file_name": "ov.png",
"compression_type": CompressionType.RAW,
"file_type": FileType.TEXTURE
},
{
"path": "data/wip_data/complete_spritesheet.png",
"file_name": "castle.png",
"compression_type": CompressionType.RAW,
"file_type": FileType.TEXTURE
},
{
"path": "data/wip_data/map.wrm",
"file_name": "map.wrm",
"compression_type": CompressionType.RAW,
"file_type": FileType.MAP
},
{
"path": "data/wip_data/set.wts",
"file_name": "set.wts",
"compression_type": CompressionType.RAW,
"file_type": FileType.MAP
},
{
"path": "data/wip_data/haeccity.png",
"file_name": "t_haecci",
"compression_type": CompressionType.RAW,
"file_type": FileType.TEXTURE
},
{
"path": "data/wip_data/haeccity",
"file_name": "f_haecci",
"compression_type": CompressionType.RAW,
"file_type": FileType.UNKNOWN
}
]}
def bundle(files, path_out):
for f in files["file_entries"]:
if 'path' in f:
with open(f["path"], "rb") as o:
f["data"] = o.read()
print(f['file_name'])
f["file_name"] = f["file_name"].encode('ascii')
out = pack.pack_archive(files)
f = open(path_out, "wb+")
f.write(out)
if __name__ == '__main__':
bundle(minimal_data, "wrpg_core.wrf")
bundle(wip_wrpg_data, "wip_data.wrf")