jackdpage / python-gdtf

Python library for General Device Type Format
MIT License
4 stars 2 forks source link

DMXChannel without Offset breaking parser #1

Closed hugoaboud closed 3 years ago

hugoaboud commented 3 years ago

Hi, I'm setting up your library to parse GDTF profiles, however it failed with the following error:

File "C:\Users\Aboud\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\addons\dmx\pygdtf__init__.py", line 592, in _read_xml self.offset = [int(i) for i in xml_node.attrib.get('Offset')] TypeError: 'NoneType' object is not iterable

I was testing this FixtureType. I found that the first DMXChannel of the file has no Offset parameter, since it's zero.

I'm not sure what the standard says about it, so I didn't make a pull request. However, it's an easy fix. Please let me know what you think it's the best strategy here: reporting the file problem to GDTF-Share, including the fix or both.

offset = xml_node.attrib.get('Offset')
if (offset != None):
    self.offset = [int(i) for i in offset.split(',')]
else:
    self.offset = [0]

Also, thank you for the work on this library! It's gonna make life so much easier!

jackdpage commented 3 years ago

Hi, sorry if I'm a bit late with this one - I have just pushed a change along these lines

According to the standard, the default value for Offset is "None", so I have added this as the fallback value if a value isn't provided. I've tested this with the fixture you've linked. Note I have used the string "None" rather than builtin None to keep in line with the documentation they provide

Cheers