Skip to content

Improvements on Element value parser and display

Benoit Seignovert requested to merge add-support-for-lists-and-tuples into main

Implements multiple suggestions from @lpenasa to improve PTR Element value parser and display:

  • Raise an AttributeError on ElementWindow attribute edits:
>>> obs = ObsBlock('2032-01-01T10', '2032-01-01T12')
>>> obs.start = 'foo'
AttributeError: can't set attribute 'start'
  • Add xml representation of iterable in Element (separated with double spaces):
>>> Element('foo', [1, 2, 3])
<foo> 1  2  3 </foo>
  • Add Element.value type parsing:
>>> Element('foo', [1, 2, 3]).value
[1, 2, 3]

>>> Element('foo', '2032-01-01').value
datetime.datetime(2032, 1, 1, 0, 0)
  • Return self on Element.set_value() method:
>>> el = Element('foo', 'bar')
>>> el.set_value('baz')
<foo> baz </foo>
  • Fix PTX parser and AGM simulator on non-stripped PTR content:
>>> read_ptr('''
<startTime> 2034-03-20T15:22:25 </startTime>
''')
<startTime> 2034-03-20T15:22:25 </startTime>

Minor changes:

  • Customize Element indentation value:
>>> Element.INDENT
'  '
  • Update B. Seignovert affiliation.

Closes #2 (closed)

Merge request reports