Skip to content

Commit cfd4277

Browse files
committed
Fix handling of arrays with basic types
Elements of type 'ArrayOf' occur in two flowers: - Either defined with types of the "xs" namespace like "ArrayOfString" - Or defined with types of the the "tns" namespace like "ArrayOfProgram". This fixes parsing of list-elements of the basic namespace 'xs'.
1 parent 1c9035e commit cfd4277

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

mythtv/bindings/python/MythTV/mythservices.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,19 @@ def _parse_subtree(item):
229229
if t.get('type') is not None:
230230
type_ns, type_value = t.get('type').split(':')
231231
if (t.get('maxOccurs', '') == 'unbounded'):
232-
# add arrays immediately
233232
if type_ns == 'xs':
234-
# basic type, add conversion rule
233+
# basic type, add conversion rule for the elements
235234
t_value = _get_type(t.get('type'),
236235
t.get('nillable', None))
237236
else:
237+
# add arrays of type 'tns' immediately
238238
t_value = type_value
239239
d_list.append({item.get('name') : [t_value]})
240240
continue
241241
elif (type_ns == 'xs'):
242242
element_dict[t.get('name')] = \
243-
_get_type(t.get('type'),
244-
t.get('nillable', None))
243+
_get_type(t.get('type'),
244+
t.get('nillable', None))
245245
else:
246246
element_dict[t.get('name')] = type_value
247247
else:
@@ -252,8 +252,8 @@ def _parse_subtree(item):
252252
type_ns, type_value = t.get('type').split(':')
253253
if (type_ns == 'xs'):
254254
element_dict[t.get('name')] = \
255-
_get_type(t.get('type'),
256-
t.get('nillable', None))
255+
_get_type(t.get('type'),
256+
t.get('nillable', None))
257257
else:
258258
element_dict[t.get('name')] = type_value
259259

@@ -369,12 +369,17 @@ def fromEtree(self, xml_etree, schema_tag=None):
369369
# handle 'ArrayOf', 'MapOf', '.Type' explicitely
370370
if tvalue.startswith('ArrayOf'):
371371
arr = []
372-
for c in child.getchildren():
373-
i = MythServiceData(self.service,
374-
self.host,
375-
port=self.port,
376-
xml_etree=c)
377-
arr.append(i)
372+
if isinstance(self.schema_dict[tvalue][0], int):
373+
# array of basic type 'xs', type already known:
374+
for c in child.getchildren():
375+
arr.append(c.text)
376+
else:
377+
for c in child.getchildren():
378+
i = MythServiceData(self.service,
379+
self.host,
380+
port=self.port,
381+
xml_etree=c)
382+
arr.append(i)
378383
self.data.append(arr)
379384
self._field_order.append(child.tag.lower())
380385
# 'ArrayOf' has it's own type representation:

0 commit comments

Comments
 (0)