#!/usr/local/bin/python import sys,time step = sys.argv[1] if step == "init": me = sys.argv[0] outfile = open(sys.argv[2],'w') today = time.strftime("%a %d %b %Y",time.localtime(time.time())) outfile.write("//Gif data generated " + today + " by " + me + "\n\n") if step == "file": outfile = open(sys.argv[2],'a') # Read the whole gif file into one big string: x = open(sys.argv[4],'rb').read() icon = sys.argv[3] outfile.write("\nconst char " + icon + "Icon[] = {\n") i = 0 while i < (len(x)-1): outfile.write("0x%02x, " % ord(x[i])) i = i + 1 if (i%8 == 0): outfile.write("\n") outfile.write("0x%02x };\n\n" % ord(x[i])) outfile.flush() outfile.close()