blob: b0cd4c45e99f24eca481c58e0468d5a3065c6170 (
plain)
| 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
 | #!/usr/bin/env python
# encoding: utf-8
import sys
import re
import os
import zipfile
try:
    import zlib
    compression = zipfile.ZIP_DEFLATED
except:
    compression = zipfile.ZIP_STORED
PACK_FILE_EXTENSIONS = ('.xml', '.bmp')
def buildPack(packName):
	if not os.path.isdir(packName):
		print ("Invalid pack name: " + packName)
		return
	zf = zipfile.ZipFile(packName + ".zip", 'w')
	zf.compress_type = zipfile.ZIP_DEFLATED
	print ("Building '" + packName + "' pack:")
	os.chdir(packName)
	for filename in os.listdir('.'):
		if os.path.isfile(filename) and not filename[0] == '.' and filename.endswith(PACK_FILE_EXTENSIONS):
			zf.write(filename, './' + filename, compress_type=compression)
			print ("    Adding file: " + filename)
	os.chdir('../')
	zf.close()
def buildAllPacks():
	for f in os.listdir('.'):
		if os.path.isdir(os.path.join('.', f)) and not f[0] == '.':
			buildPack(f)
def printUsage():
	print ("===============================================")
	print ("ScummVM Virtual Keyboard Pack Generation Script")
	print ("===============================================")
	print ("Usage:")
	print ("vkeybdpack.py makeall")
	print ("    Builds all the available pack.\n")
	print ("vkeybdpack.py make [packname]")
	print ("    Builds the pack called 'packname'.\n")
def main():
	if len(sys.argv) == 2 and sys.argv[1] == "makeall":
		buildAllPacks()
	elif len(sys.argv) == 3 and sys.argv[1] == "make":
		buildPack(sys.argv[2])
	else:
		printUsage()
if __name__ == "__main__":
	sys.exit(main())
 |