OSDN Git Service

removing dead code
authorMartin Renold <martinxyz@gmx.ch>
Sat, 27 Jun 2009 09:34:27 +0000 (11:34 +0200)
committerMartin Renold <martinxyz@gmx.ch>
Sat, 27 Jun 2009 09:34:27 +0000 (11:34 +0200)
This used to be stroke serialization for an undo-based file format.

lib/document.py
lib/serialize.py [deleted file]
lib/stroke.py

index cb8a8ea..70148f1 100644 (file)
@@ -26,7 +26,7 @@ A document:
 """
 
 import mypaintlib, helpers, tiledsurface, pixbufsurface
-import command, stroke, layer, serialize
+import command, stroke, layer
 import brush # FIXME: the brush module depends on gtk and everything, but we only need brush_lowlevel
 import gzip, os, zipfile, tempfile, numpy, time
 join = os.path.join
diff --git a/lib/serialize.py b/lib/serialize.py
deleted file mode 100644 (file)
index 7960968..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-
-def save(obj, f):
-    for name, type in obj.serialize_members:
-        data = getattr(obj, name)
-        if type is str:
-            assert isinstance(data, str)
-            f.write('%d\n' % len(data))
-            f.write(data)
-        elif type is int:
-            f.write('%d\n' % data)
-        elif type is float:
-            # FIXME: inefficient
-            f.write('%s\n' % repr(data))
-        else:
-            assert False, 'unknown type'
-
-def load(obj, f):
-    for name, type in obj.serialize_members:
-        if type is str:
-            length = int(f.readline())
-            data = f.read(length)
-            assert len(data) == length
-            setattr(obj, name, data)
-        elif type is int:
-            setattr(obj, name, int(f.readline()))
-        elif type is float:
-            setattr(obj, name, float(f.readline()))
-        else:
-            assert False, 'unknown type'
-    if hasattr(obj, 'after_unserialize'): # FIXME: inconsistent name
-        obj.after_unserialize()
-    
index b4ea50e..1c38d62 100644 (file)
@@ -12,6 +12,7 @@ import random
 
 class Stroke:
     # A "finished" stroke object is immutable, except right after creation (when it has never been fully rendered).
+    # To modify an existing stroke, the old one must be deleted and a new Stroke instance must be used to replace it.
     serial_number = 0
     def __init__(self):
         self.finished = False
@@ -88,13 +89,3 @@ class Stroke:
         # has different meanings for the states. This should cause
         # fewer glitches than resetting the initial state to zero.
         return s
-
-    serialize_members = [
-        ('total_painting_time', float),
-        ('brush_settings', str),
-        ('brush_state', str),
-        ('stroke_data', str),
-        ]
-    def after_unserialize(self):
-        assert not self.finished
-        self.finished = True