Skip to content

Commit

Permalink
fixes #119, refs #117
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Dec 14, 2017
1 parent 55a9d37 commit d4eb61d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Change History
Production
**********

:pending:

* `#119 <https://github.com/prjemian/spec2nexus/issues/119>`_
delimiters in #H/#V lines with or without text values

:2017.901.4:

* `#62 <https://github.com/prjemian/spec2nexus/issues/62>`_
Expand Down
13 changes: 11 additions & 2 deletions src/spec2nexus/plugins/unicat_spec2nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""


import re
from spec2nexus.plugin import ControlLineHandler
from spec2nexus.utils import strip_first_word, split_column_labels
from spec2nexus import eznx
Expand Down Expand Up @@ -52,7 +53,8 @@ class UNICAT_MetadataMnemonics(ControlLineHandler):
key = '#H\d+'

def process(self, text, spec_obj, *args, **kws):
spec_obj.H.append( strip_first_word(text).split() )
labels = strip_first_word(text).split()
spec_obj.H.append(labels)


class UNICAT_MetadataValues(ControlLineHandler):
Expand Down Expand Up @@ -87,7 +89,14 @@ class UNICAT_MetadataValues(ControlLineHandler):
key = '#V\d+'

def process(self, text, scan, *args, **kws):
scan.V.append(split_column_labels(strip_first_word(text)))
index = len(scan.V)
row_text = strip_first_word(text)
for delimiter in (r" "*2, r" "):
values = re.split(delimiter, row_text)
if len(scan.header.H[index]) == len(values):
break
# issue #107: values = split_column_labels(row_text)
scan.V.append(values)
scan.addPostProcessor('unicat_metadata', self.postprocess)

def postprocess(self, scan, *args, **kws):
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def suite(*args, **kw):
from tests import issue64
from tests import issue99_hklscan
from tests import issue107
from tests import issue119
test_suite = unittest.TestSuite()
test_list = [
data_03_06_JanTest,
Expand Down
2 changes: 1 addition & 1 deletion tests/issue107.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_data_file(self):
self.assertTrue(hasattr(scan.header, "H"))
scan.interpret()
self.assertTrue(hasattr(scan, "metadata"))
self.assertEqual(len(scan.metadata), 135)
self.assertEqual(len(scan.metadata), 140)

self.assertTrue(isinstance(scan, spec2nexus.spec.SpecDataFileScan))

Expand Down

0 comments on commit d4eb61d

Please sign in to comment.