def squeezeGeneratedCode(self, outputDir, deleteSource=True): # Since we will be squeezing the importModuleName file, rename # the original to something we can import from within the # squeezed version. squeezedName = FFIConstants.importModuleName unsqueezedName = FFIConstants.importModuleName + 'Unsqueezed' os.rename(os.path.join(outputDir, squeezedName + '.py'), os.path.join(outputDir, unsqueezedName + '.py')) # Get the list of files to squeeze. This is all of the .py # files in the output directory except for the __init__.py # file. files = glob.glob(os.path.join(outputDir, '*.py')) init = os.path.join(outputDir, '__init__.py') try: files.remove(init) except: pass print "Squeezing %s files." % (len(files)) from direct.showbase import pandaSqueezeTool pandaSqueezeTool.squeeze(squeezedName, unsqueezedName, files, outputDir) if deleteSource: # Remove the now-squeezed source files. for file in files: os.remove(file)