Implement the plain-text HistoryRecord, RecreationRecord, and GetHistoryRecord.
authorW. Trevor King <wking@tremily.us>
Thu, 19 Jul 2012 12:31:11 +0000 (08:31 -0400)
committerW. Trevor King <wking@tremily.us>
Thu, 19 Jul 2012 14:50:48 +0000 (10:50 -0400)
bin/igorbinarywave.py
igor/record/__init__.py
igor/record/base.py
igor/record/gethistory.py [deleted file]
igor/record/history.py
igor/record/recreation.py [deleted file]
test/test.py

index 435fdcaa24ff611cc35bbcd5f877afdfe1ae1c10..f3da1cd79a243f4b1de79bc45f67164d66c81d3b 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env python
+#
+# Copyright
 
 "IBW -> ASCII conversion"
 
index ffa64565918107e82ce663ee47f7aeef22908e29..faaa61d0c8e785520332644b5960d6cd15a02180 100644 (file)
@@ -5,11 +5,9 @@
 
 from .base import Record, UnknownRecord, UnusedRecord
 from .variables import VariablesRecord
-from .history import HistoryRecord
+from .history import HistoryRecord, RecreationRecord, GetHistoryRecord
 from .wave import WaveRecord
-from .recreation import RecreationRecord
 from .procedure import ProcedureRecord
-from .gethistory import GetHistoryRecord
 from .packedfile import PackedFileRecord
 from .folder import FolderStartRecord, FolderEndRecord
 
index a6990f8d423633d6b911421a0eddf74aa58d4921..454e7396fbc2202f4d53a917f2ccc0d41b1a6bb3 100644 (file)
@@ -22,3 +22,14 @@ class UnknownRecord (Record):
 
 class UnusedRecord (Record):
     pass
+
+
+# Copyright
+
+from .base import Record
+
+
+class TextRecord (Record):
+    def __init__(self, *args, **kwargs):
+        super(TextRecord, self).__init__(*args, **kwargs)
+        self.text = str(self.data).replace('\r\n', '\n').replace('\r', '\n')
diff --git a/igor/record/gethistory.py b/igor/record/gethistory.py
deleted file mode 100644 (file)
index d2e5c20..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright
-
-from .base import Record
-
-
-class GetHistoryRecord (Record):
-    pass
index 0974cace351a52d6e0348d2f3af1cdb56ccfad79..4d39b759b45a2e14fb84b2eefcda941f4bccbe7c 100644 (file)
@@ -1,7 +1,15 @@
 # Copyright
 
-from .base import Record
+from .base import TextRecord
 
 
-class HistoryRecord (Record):
+class HistoryRecord (TextRecord):
+    pass
+
+
+class RecreationRecord (TextRecord):
+    pass
+
+
+class GetHistoryRecord (TextRecord):
     pass
diff --git a/igor/record/recreation.py b/igor/record/recreation.py
deleted file mode 100644 (file)
index 3bc9cb4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright
-
-from .base import Record
-
-
-class RecreationRecord (Record):
-    pass
index 3fd208f38e59e462379a54078379a7b6bf7eda74..2051c9a2de2f84d8df4a8bb4fd7b440fb4c26081 100644 (file)
@@ -664,7 +664,7 @@ record 30:
  'userStrs': {},
  'userVars': {}}
 record 31:
-<HistoryRecord ...>
+'\x95 Polar Graphs Demo, v3.01\n\n'
 record 32:
 (array([ 0.30000001,  0.5448544 ,  0.77480197,  0.97584349,  1.13573945,
         1.24475539,  1.2962544 ,  1.28710103,  1.21785283,  1.09272552,
@@ -1321,9 +1321,9 @@ record 46:
 record 47:
 <FolderEndRecord ...>
 record 48:
-<RecreationRecord ...>
+'| Platform=Windows95, IGORVersion=3.130\n\n\n\nMoveWindow/P 5.25,40.25,504.75,335\n...hook=PolarWindowHook\nEndMacro\n'
 record 49:
-<GetHistoryRecord ...>
+''
 record 50:
 <ProcedureRecord ...>
 """
@@ -1334,6 +1334,7 @@ import sys
 
 from igor.binarywave import load as loadibw
 from igor.packed import load as loadpxp
+from igor.record.base import TextRecord
 from igor.record.variables import VariablesRecord
 from igor.record.wave import WaveRecord
 
@@ -1355,7 +1356,9 @@ def dumppxp(filename, strict=True):
     records = loadpxp(path, strict=strict)
     for i,record in enumerate(records):
         print('record {}:'.format(i))
-        if isinstance(record, VariablesRecord):
+        if isinstance(record, TextRecord):
+            pprint(record.text)
+        elif isinstance(record, VariablesRecord):
             pprint(record.variables)
         elif isinstance(record, WaveRecord):
             pprint(record.wave)