Browse Source

Updated to squeeze pandamodules not showbaseglobal

Mark Mine 22 years ago
parent
commit
5c6aa9b77c
1 changed files with 33 additions and 10 deletions
  1. 33 10
      direct/src/showbase/pandaSqueezer.py

+ 33 - 10
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()