[flickrpy] r54 committed - applied patch (with minor modifications for style) from issue 20 (impl...

0 views
Skip to first unread message

flic...@googlecode.com

unread,
May 2, 2012, 12:35:27 PM5/2/12
to flickrp...@googlegroups.com
Revision: 54
Author: jimsaku
Date: Wed May 2 09:35:15 2012
Log: applied patch (with minor modifications for style) from issue 20
(implementation of getAllContexts
http://code.google.com/p/flickrpy/source/detail?r=54

Modified:
/trunk/flickr.py

=======================================
--- /trunk/flickr.py Wed May 2 09:19:21 2012
+++ /trunk/flickr.py Wed May 2 09:35:15 2012
@@ -222,6 +222,34 @@
self.__title = title
self.__description = description

+ def getAllContexts(self):
+ """Retrieves lists of the pools/sets the photo is in"""
+ method = 'flickr.photos.getAllContexts'
+ data = _doget(method, photo_id=self.id)
+ d = {'pools': [], 'sets': []}
+ if hasattr(data.rsp, "pool"):
+ if isinstance(data.rsp.pool, list):
+ for pool in data.rsp.pool:
+ d["pools"].append({"id": pool.id, "title": pool.title})
+ else:
+ d["pools"].append({"id": data.rsp.pool.id, "title":
data.rsp.pool.title})
+ if hasattr(data.rsp, "set"):
+ if isinstance(data.rsp.set, list):
+ for theset in data.rsp.set:
+ d["sets"].append({"id": theset.id, "title":
theset.title})
+ else:
+ d["sets"].append({"id": data.rsp.set.id, "title":
data.rsp.set.title})
+ return d
+
+ def getPoolCount(self):
+ """Retrieves a count of the pools the photo is in"""
+ d = self.getAllContexts()
+ return len( d["pools"] )
+
+ def getSetCount(self):
+ """Retrieves a count of the pools the photo is in"""
+ d = self.getAllContexts()
+ return len( d["sets"] )

def getURL(self, size='Medium', urlType='url'):
"""Retrieves a url for the photo. (flickr.photos.getSizes)
Reply all
Reply to author
Forward
0 new messages