<s> import sys <EOL> import optparse <EOL> import glob <EOL> import os <EOL> import string <EOL> import tempfile <EOL> import shutil <EOL> import zipfile <EOL> from pipelinetools import * <EOL> from objloader import * <EOL> import struct <EOL> def ProcessFile ( file , options ) : <EOL> basename = os . path . splitext ( os . path . basename ( file ) ) [ <NUM_LIT:0> ] <EOL> print "<STR_LIT>" + basename <EOL> basedir = GetBaseDirectory ( file , "<STR_LIT>" ) <EOL> tooldir = VerifyDirectory ( basedir , "<STR_LIT>" ) <EOL> outdir = VerifyDirectory ( basedir , "<STR_LIT>" ) <EOL> tempdir = tempfile . mkdtemp ( ) <EOL> tempvbname = os . path . join ( tempdir , "<STR_LIT>" ) <EOL> inzip = zipfile . ZipFile ( file , "<STR_LIT:r>" ) <EOL> objfile = ObjFile ( inzip . open ( "<STR_LIT>" ) ) <EOL> if options . bigendian : <EOL> endianstring = "<STR_LIT:>>" <EOL> else : <EOL> endianstring = "<STR_LIT:<>" <EOL> outfile = open ( tempvbname , '<STR_LIT:wb>' ) <EOL> for face in objfile . faces : <EOL> for vert in face : <EOL> pos = objfile . vertices [ vert [ <NUM_LIT:0> ] - <NUM_LIT:1> ] <EOL> tex = objfile . texcoords [ vert [ <NUM_LIT:1> ] - <NUM_LIT:1> ] <EOL> norms = objfile . normals [ vert [ <NUM_LIT:2> ] - <NUM_LIT:1> ] <EOL> packed = struct . pack ( endianstring + "<STR_LIT>" , pos [ <NUM_LIT:0> ] , pos [ <NUM_LIT:1> ] , pos [ <NUM_LIT:2> ] , norms [ <NUM_LIT:0> ] , norms [ <NUM_LIT:1> ] , norms [ <NUM_LIT:2> ] , tex [ <NUM_LIT:0> ] , tex [ <NUM_LIT:1> ] ) <EOL> outfile . write ( packed ) <EOL> outfile . close ( ) <EOL> inzip . extract ( "<STR_LIT>" , tempdir ) <EOL> outzip = zipfile . ZipFile ( os . path . join ( outdir , basename + "<STR_LIT>" ) , "<STR_LIT:w>" ) <EOL> for f in [ tempvbname , os . path . join ( tempdir , "<STR_LIT>" ) ] : <EOL> outzip . write ( f , os . path . relpath ( f , tempdir ) , zipfile . ZIP_DEFLATED ) <EOL> shutil . rmtree ( tempdir ) <EOL> def main ( argv ) : <EOL> try : <EOL> import psyco <EOL> psyco . full ( ) <EOL> except ImportError : <EOL> pass <EOL> parser = optparse . OptionParser ( description = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , help = "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" ) <EOL> options , arguments = parser . parse_args ( ) <EOL> files = list ( set ( sum ( [ glob . glob ( x ) for x in arguments ] , [ ] ) ) ) <EOL> if len ( files ) == <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> for file in files : <EOL> ProcessFile ( file , options ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
