Commit 29b3524c authored by W. Trevor King's avatar W. Trevor King
Browse files

Implement the plain-text HistoryRecord, RecreationRecord, and GetHistoryRecord.

parent d400cacf
#!/usr/bin/env python
#
# Copyright
"IBW -> ASCII conversion"
......
......@@ -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
......
......@@ -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')
# Copyright
from .base import Record
class GetHistoryRecord (Record):
pass
# Copyright
from .base import Record
from .base import TextRecord
class HistoryRecord (Record):
class HistoryRecord (TextRecord):
pass
class RecreationRecord (TextRecord):
pass
class GetHistoryRecord (TextRecord):
pass
# Copyright
from .base import Record
class RecreationRecord (Record):
pass
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment