get_tag() refactored to use _sessionget()
authorMarek Marecki <triviuss@gmail.com>
Fri, 29 Mar 2013 10:49:44 +0000 (11:49 +0100)
committerMarek Marecki <triviuss@gmail.com>
Fri, 29 Mar 2013 10:49:44 +0000 (11:49 +0100)
diaspy/client.py

index 1a53851d1c534696515f6d7290b2706878423cb8..37691c2c19cfc2c53f05ed5b4086ee8ef52289cf 100644 (file)
@@ -34,6 +34,7 @@ class Client:
         :param string: URL to get without the pod's URL and slash eg. 'stream'.
         :type string: str
         """
+        data = 
         return self.session.get('{0}/{1}'.format(self.pod, string))
 
     def get_token(self):
@@ -180,16 +181,13 @@ class Client:
         :returns: list -- list of Post objects
         """
         data = {'authenticity_token': self.get_token()}
-        #r = self.session.get('/mentions.json'.format(self.pod))
         r = self._sessionget('mentions.json')
 
         if r.status_code != 200:
             raise Exception('wrong status code: {0}'.format(r.status_code))
 
         mentions = r.json()
-        posts = [ diaspy.models.Post(str(post['id']), self) for post in mentions ]
-
-        return posts
+        return [ diaspy.models.Post(str(post['id']), self) for post in mentions ]
 
     def get_tag(self, tag):
         """This functions returns a list of posts containing the tag.
@@ -197,19 +195,15 @@ class Client:
         :type tag: str
 
         :returns: list -- list of Post objects
-
         """
-
         data = {'authenticity_token': self.get_token()}
-        r = self.session.get('{0}/tags/{1}.json'.format(self.pod, tag))
+        r = self._sessionget('tags/{0}.json'.format(tag))
 
         if r.status_code != 200:
             raise Exception('wrong status code: {0}'.format(r.status_code))
 
         tagged_posts = r.json()
-        posts = [ diaspy.models.Post(str(post['id']), self) for post in tagged_posts ]
-
-        return posts
+        return [ diaspy.models.Post(str(post['id']), self) for post in tagged_posts ]
 
     def add_user_to_aspect(self, user_id, aspect_id):
         """ this function adds a user to an aspect.