ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

vkeybdpack.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # encoding: utf-8
00003 import sys
00004 import re
00005 import os
00006 import zipfile
00007 try:
00008     import zlib
00009     compression = zipfile.ZIP_DEFLATED
00010 except:
00011     compression = zipfile.ZIP_STORED
00012 
00013 PACK_FILE_EXTENSIONS = ('.xml', '.bmp')
00014 
00015 def buildPack(packName):
00016     if not os.path.isdir(packName):
00017         print ("Invalid pack name: " + packName)
00018         return
00019 
00020     zf = zipfile.ZipFile(packName + ".zip", 'w')
00021 
00022     zf.compress_type = zipfile.ZIP_DEFLATED
00023 
00024     print ("Building '" + packName + "' pack:")
00025     os.chdir(packName)
00026 
00027     for filename in os.listdir('.'):
00028         if os.path.isfile(filename) and not filename[0] == '.' and filename.endswith(PACK_FILE_EXTENSIONS):
00029             zf.write(filename, './' + filename, compress_type=compression)
00030             print ("    Adding file: " + filename)
00031 
00032     os.chdir('../')
00033 
00034     zf.close()
00035 
00036 def buildAllPacks():
00037     for f in os.listdir('.'):
00038         if os.path.isdir(os.path.join('.', f)) and not f[0] == '.':
00039             buildPack(f)
00040 
00041 def printUsage():
00042     print ("===============================================")
00043     print ("ScummVM Virtual Keyboard Pack Generation Script")
00044     print ("===============================================")
00045     print ("Usage:")
00046     print ("vkeybdpack.py makeall")
00047     print ("    Builds all the available pack.\n")
00048     print ("vkeybdpack.py make [packname]")
00049     print ("    Builds the pack called 'packname'.\n")
00050 
00051 def main():
00052 
00053     if len(sys.argv) == 2 and sys.argv[1] == "makeall":
00054         buildAllPacks()
00055 
00056     elif len(sys.argv) == 3 and sys.argv[1] == "make":
00057         buildPack(sys.argv[2])
00058 
00059     else:
00060         printUsage()
00061 
00062 if __name__ == "__main__":
00063     sys.exit(main())


Generated on Sat Feb 16 2019 05:01:11 for ResidualVM by doxygen 1.7.1
curved edge   curved edge