From b2eefdadfabafe0d41906d54d83a81c20268b96a Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 1 Jul 2009 14:01:27 -0800 Subject: [PATCH] use kwargs a bit better... drop addContainer, it wasn't used, and didn't make much sense as we normally addItem Containers directly, instead of creating a Container.. make example work again.. [git-p4: depot-paths = "//depot/": change = 1349] --- DIDLLite.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/DIDLLite.py b/DIDLLite.py index 8162ec7..705075c 100644 --- a/DIDLLite.py +++ b/DIDLLite.py @@ -89,8 +89,8 @@ class Object(object): content = property(lambda x: x._content) needupdate = None # do we update before sending? (for res) - def __init__(self, cd, id, parentID, title, restricted = False, - creator = None, **kwargs): + def __init__(self, cd, id, parentID, title, restricted=False, + creator=None, **kwargs): self.cd = cd self.id = id @@ -297,10 +297,8 @@ class Container(Object, list): updateID = 0 needupdate = False - def __init__(self, cd, id, parentID, title, restricted = 0, - creator = None, **kwargs): - Object.__init__(self, cd, id, parentID, title, restricted, - creator, **kwargs) + def __init__(self, cd, id, parentID, title, **kwargs): + Object.__init__(self, cd, id, parentID, title, **kwargs) list.__init__(self) self.doingUpdate = False self.oldchildren = {} @@ -513,10 +511,6 @@ class DIDLElement(_ElementInterface): self.attrib['xmlns:dc'] = 'http://purl.org/dc/elements/1.1/' self.attrib['xmlns:upnp'] = 'urn:schemas-upnp-org:metadata-1-0/upnp' - def addContainer(self, id, parentID, title, restricted = False): - e = Container(id, parentID, title, restricted, creator = '') - self.append(e.toElement()) - def addItem(self, item): self.append(item.toElement()) @@ -529,9 +523,9 @@ class DIDLElement(_ElementInterface): if __name__ == '__main__': root = DIDLElement() - root.addContainer('0\Movie\\', '0\\', 'Movie') - root.addContainer('0\Music\\', '0\\', 'Music') - root.addContainer('0\Photo\\', '0\\', 'Photo') - root.addContainer('0\OnlineMedia\\', '0\\', 'OnlineMedia') + root.addItem(Container(None, '0\Movie\\', '0\\', 'Movie')) + root.addItem(Container(None, '0\Music\\', '0\\', 'Music')) + root.addItem(Container(None, '0\Photo\\', '0\\', 'Photo')) + root.addItem(Container(None, '0\OnlineMedia\\', '0\\', 'OnlineMedia')) print tostring(root)