[chocolate-doom] 23/29: Don't write converted output file unless everything went through okay.

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 30 15:06:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to annotated tag chocolate-doom-0.0.4
in repository chocolate-doom.

commit e2896ba221018d26c27201716a82945e2b005973
Author: Simon Howard <fraggle at gmail.com>
Date:   Tue Sep 27 22:23:32 2005 +0000

    Don't write converted output file unless everything went through
    okay.
    
    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 137
---
 src/Makefile.am  |  2 +-
 src/convert-icon | 33 +++++++++++++++++++--------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 163eb5b..f2b0277 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,5 +41,5 @@ EXTRA_DIST = convert-icon chocolate_doom_icon.c
 	windres $^ -o $@
 
 chocolate_doom_icon.c : ../data/chocolate-doom.png
-	./convert-icon $^ > $@
+	./convert-icon $^ $@
 
diff --git a/src/convert-icon b/src/convert-icon
index a55d813..9c093b8 100755
--- a/src/convert-icon
+++ b/src/convert-icon
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# $Id: convert-icon 126 2005-09-24 22:04:03Z fraggle $
+# $Id: convert-icon 137 2005-09-27 22:23:32Z fraggle $
 #
 # Copyright(C) 2005 Simon Howard
 #
@@ -22,6 +22,10 @@
 # Converts images into C structures to be inserted in programs
 #
 # $Log$
+# Revision 1.2  2005/09/27 22:23:32  fraggle
+# Don't write converted output file unless everything went through
+# okay.
+#
 # Revision 1.1  2005/09/24 22:04:03  fraggle
 # Add application icon to running program
 #
@@ -31,41 +35,42 @@ import sys
 import os
 import re
 
-def convert_image(filename):
+def convert_image(filename, output_filename):
 
     im = Image.open(filename).convert("RGB")
 
+    outfile = open(output_filename, "w")
+
     size = im.size
 
     struct_name = os.path.basename(filename)
     struct_name = re.sub(re.compile("\\..*$"), "", struct_name)
     struct_name = re.sub(re.compile("\W"), "_", struct_name)
 
-    print "static int %s_w = %i;" % (struct_name, size[0])
-    print "static int %s_h = %i;" % (struct_name, size[1])
+    outfile.write("static int %s_w = %i;\n" % (struct_name, size[0]))
+    outfile.write("static int %s_h = %i;\n" % (struct_name, size[1]))
 
-    print
-    print "static unsigned char %s_data[] = {" % (struct_name)
+    outfile.write("\n")
+    outfile.write("static unsigned char %s_data[] = {\n" % (struct_name))
 
     elements_on_line = 0
 
-    print "    ",
+    outfile.write("    ")
 
     for y in range(size[1]):
         for x in range(size[0]):
             val = im.getpixel((x, y))
-            print "%i,%i,%i,  " % val,
+            outfile.write("%i,%i,%i,  " % val)
             elements_on_line += 1
 
             if elements_on_line > 4:
                 elements_on_line = 0
-                print 
-                print "    ",
+                outfile.write("\n")
+                outfile.write("    ")
 
-    print 
-    print "};\n"
+    outfile.write("\n")
+    outfile.write("};\n")
 
-for filename in sys.argv[1:len(sys.argv)]:
-    convert_image(filename)
+convert_image(sys.argv[1], sys.argv[2])
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list