From: W. Trevor King Date: Thu, 19 Jul 2012 12:31:11 +0000 (-0400) Subject: Implement the plain-text HistoryRecord, RecreationRecord, and GetHistoryRecord. X-Git-Tag: v0.2~33 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=29b3524c6aea12300f5db5371e1d0bdbc7032f1e;p=igor.git Implement the plain-text HistoryRecord, RecreationRecord, and GetHistoryRecord. --- diff --git a/bin/igorbinarywave.py b/bin/igorbinarywave.py index 435fdca..f3da1cd 100755 --- a/bin/igorbinarywave.py +++ b/bin/igorbinarywave.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +# +# Copyright "IBW -> ASCII conversion" diff --git a/igor/record/__init__.py b/igor/record/__init__.py index ffa6456..faaa61d 100644 --- a/igor/record/__init__.py +++ b/igor/record/__init__.py @@ -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 diff --git a/igor/record/base.py b/igor/record/base.py index a6990f8..454e739 100644 --- a/igor/record/base.py +++ b/igor/record/base.py @@ -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 index d2e5c20..0000000 --- a/igor/record/gethistory.py +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright - -from .base import Record - - -class GetHistoryRecord (Record): - pass diff --git a/igor/record/history.py b/igor/record/history.py index 0974cac..4d39b75 100644 --- a/igor/record/history.py +++ b/igor/record/history.py @@ -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 index 3bc9cb4..0000000 --- a/igor/record/recreation.py +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright - -from .base import Record - - -class RecreationRecord (Record): - pass diff --git a/test/test.py b/test/test.py index 3fd208f..2051c9a 100644 --- a/test/test.py +++ b/test/test.py @@ -664,7 +664,7 @@ record 30: 'userStrs': {}, 'userVars': {}} record 31: - +'\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: record 48: - +'| Platform=Windows95, IGORVersion=3.130\n\n\n\nMoveWindow/P 5.25,40.25,504.75,335\n...hook=PolarWindowHook\nEndMacro\n' record 49: - +'' record 50: """ @@ -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)