From 5c6aa9b77cc9a07c951fe564340e46d16c5014f6 Mon Sep 17 00:00:00 2001 From: Mark Mine Date: Fri, 20 Jun 2003 01:30:25 +0000 Subject: [PATCH] Updated to squeeze pandamodules not showbaseglobal --- direct/src/showbase/pandaSqueezer.py | 43 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/direct/src/showbase/pandaSqueezer.py b/direct/src/showbase/pandaSqueezer.py index 3efd946437..7d5da75288 100644 --- a/direct/src/showbase/pandaSqueezer.py +++ b/direct/src/showbase/pandaSqueezer.py @@ -1,20 +1,43 @@ import os +import sys +import getopt import pandaSqueezeTool # Assumption: We will be squeezing the files from C:\Panda\lib\py +try: + opts, pargs = getopt.getopt(sys.argv[1:], 'O') +except Exception, e: + # User passed in a bad option, print the error and the help, then exit + print e + print 'Usage: pass in -O for optimized' + sys.exit() + +fOptimized = 0 +# Store the option values into our variables +for opt in opts: + flag, value = opt + if (flag == '-O'): + fOptimized = 1 + print 'Squeezing pyo files' + def getSqueezeableFiles(): - directDir = os.getenv('DIRECT') - fileList = os.listdir(directDir + "\lib\py") - newFileList = [] - for i in fileList: - if i[-4:] == ".pyc": - j = directDir + "/lib/py/" + i - newFileList.append(j) - return newFileList + directDir = os.getenv('DIRECT') + fileList = os.listdir(directDir + "\lib\py") + newFileList = [] + if fOptimized: + targetFileExtension = ".pyo" + else: + targetFileExtension = ".pyc" + for i in fileList: + base,ext = os.path.splitext(i) + if (ext == ".py"): + j = directDir + "/lib/py/" + i + newFileList.append(j) + return newFileList def squeezePandaFiles(): - l = getSqueezeableFiles() - pandaSqueezeTool.squeeze("panda", "ShowBaseGlobal", l) + l = getSqueezeableFiles() + pandaSqueezeTool.squeeze("PandaModules", "PandaModulesUnsqueezed", l) squeezePandaFiles()