]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/tools/img2py.py
added missing refresh when changing focus in wxListCtrl, added test for it in the...
[wxWidgets.git] / wxPython / tools / img2py.py
index d6e7a0f0af28c1e1d29efe6e7a77bae95ddb77f7..6af6409fa22d0bd4e61d7aa3cee8190a2f6ad6c1 100644 (file)
@@ -32,7 +32,7 @@ Options:
 
 
 
-import sys, os, glob, getopt, tempfile
+import sys, os, glob, getopt, tempfile, string
 import cPickle, cStringIO, zlib
 import img2xpm
 
@@ -40,11 +40,20 @@ import img2xpm
 def crunch_data(data, compressed):
     # convert the lines to a Python list, pickle it and compress the result.
     lines = []
-    for line in data[2:]:  # skip the first two lines
-        lines.append(line[1:-3])  # chop one char from the front and three from the end
+    for line in data:
+        if line[0] == "\"":
+            # the line is typically (but not always):
+            #      [quote] <data> [quote][comma][newline]
+
+            # chop one char from the front
+            line = line[1:]
+
+            # now find the final quote and truncate there
+            quote = string.rfind(line, "\"")
+
+            # and append the remaining data to our list
+            lines.append(line[:quote])
 
-    # chop one extra char from the last line
-    lines[-1] = lines[-1][:-1]
 
     # pickle, crunch and convert it to a form suitable for embedding in code
     data = cPickle.dumps(lines)
@@ -59,6 +68,7 @@ def crunch_data(data, compressed):
     c = i = 0
     word = ""
     octdigits = "01234567"
+    hexdigits = "0123456789abcdef"
     while i < len(data):
         if data[i] != "\\":
             word = data[i]
@@ -70,9 +80,16 @@ def crunch_data(data, compressed):
                         break
                 word = data[i:i+n]
                 i = i + n
+            elif data[i+1] == 'x':
+                for n in range(2, 5):
+                    if data[i+n] not in hexdigits:
+                        break
+                word = data[i:i+n]
+                i = i + n
             else:
                 word = data[i:i+2]
                 i = i + 2
+
         l = len(word)
         if c + l >= 78-1:
             fp.write("\\\n")