From e3e8457d4e4c7a504c5a22a46df82e7d64bcdfc6 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 1 Jul 2009 14:18:04 -0800 Subject: [PATCH] clean up searchClass and createClass [git-p4: depot-paths = "//depot/": change = 1350] --- DIDLLite.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/DIDLLite.py b/DIDLLite.py index 705075c..b8a9dbe 100644 --- a/DIDLLite.py +++ b/DIDLLite.py @@ -394,6 +394,16 @@ class Container(Object, list): self.updateID = (self.updateID + 1) % (1l << 32) Container.didUpdate(self.cd['0']) + def _addSet(self, e, items): + if items is not None: + if not isinstance(items, (list, tuple)): + items = [ items ] + for i in items: + el = SubElement(root, e) + el.text = i + # XXX - how to specify? + el.attrib['includeDerived'] = '1' + def toElement(self): root = Object.toElement(self) @@ -403,14 +413,8 @@ class Container(Object, list): if self.childCount: root.attrib['childCount'] = str(self.childCount) - if self.createClass is not None: - SubElement(root, 'upnp:createclass').text = self.createClass - - if self.searchClass is not None: - if not isinstance(self.searchClass, (list, tuple)): - self.searchClass = ['searchClass'] - for i in searchClass: - SubElement(root, 'upnp:searchclass').text = i + self._addSet('upnp:createclass', self.createClass) + self._addSet('upnp:searchclass', self.searchClass) if self.searchable is not None: root.attrib['searchable'] = str(self.searchable)