From f605e88d716d3213e22b35da901fb046fb39c0f9 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Tue, 14 May 2013 22:40:13 +0200 Subject: [PATCH] Style check (flake8) --- diaspy/client.py | 3 +-- diaspy/models.py | 3 --- diaspy/people.py | 2 +- diaspy/streams.py | 38 ++++++++++++++++++++------------------ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/diaspy/client.py b/diaspy/client.py index 0874550..e5c6ddc 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -10,7 +10,7 @@ class Client: def __init__(self, pod, username='', password=''): """ `pod` can also be a diaspy.connection.Connection type and - Client() will detect it. When giving a connection there is no need + Client() will detect it. When giving a connection there is no need to pass username and password. :param pod: The complete url of the diaspora pod to use @@ -37,7 +37,6 @@ class Client: :type aspect_ids: str :param photo: path to picture file :type photo: str - :returns: diaspy.models.Post -- the Post which has been created """ post = self.stream.post(text, aspect_ids, photos, photo) diff --git a/diaspy/models.py b/diaspy/models.py index aa28b70..5fc22b9 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -6,7 +6,6 @@ class Post: .. note:: Remember that you need to have access to the post. - Remember that you also need to be logged in. """ def __init__(self, post_id, connection): """ @@ -90,7 +89,6 @@ class Post: :param text: text to comment. :type text: str - """ data = {'text': text, 'authenticity_token': self._connection.get_token()} @@ -110,7 +108,6 @@ class Post: :param comment_id: id of the comment to remove. :type comment_id: str - """ data = {'authenticity_token': self._connection.get_token()} diff --git a/diaspy/people.py b/diaspy/people.py index 29db718..e0ff129 100644 --- a/diaspy/people.py +++ b/diaspy/people.py @@ -46,7 +46,7 @@ class User: ('guid', 'guid'), ('name', 'diaspora_name'), ('avatar', 'image_urls'), - ] + ] for d, f in names: final[f] = data[d] self.data = final diff --git a/diaspy/streams.py b/diaspy/streams.py index d01a0c0..43db6cb 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -8,6 +8,7 @@ Documentation for D* JSON API taken from: http://pad.spored.de/ro/r.qWmvhSZg7rk4OQam """ + class Generic: """Object representing generic stream. Used in Tag(), Stream(), Activity() etc. @@ -129,8 +130,8 @@ class Outer(Generic): class Stream(Generic): - """The main stream containing the combined posts of the - followed users and tags and the community spotlights posts + """The main stream containing the combined posts of the + followed users and tags and the community spotlights posts if the user enabled those. """ def _setlocation(self): @@ -231,11 +232,11 @@ class Activity(Generic): class Aspects(Generic): - """This stream contains the posts filtered by - the specified aspect IDs. You can choose the aspect IDs with - the parameter `aspect_ids` which value should be - a comma seperated list of aspect IDs. - If the parameter is ommitted all aspects are assumed. + """This stream contains the posts filtered by + the specified aspect IDs. You can choose the aspect IDs with + the parameter `aspect_ids` which value should be + a comma seperated list of aspect IDs. + If the parameter is ommitted all aspects are assumed. An example call would be `aspects.json?aspect_ids=23,5,42` """ def _setlocation(self): @@ -263,7 +264,7 @@ class Aspects(Generic): class Commented(Generic): - """This stream contains all posts + """This stream contains all posts the user has made a comment on. """ def _setlocation(self): @@ -278,7 +279,7 @@ class Liked(Generic): class Mentions(Generic): - """This stream contains all posts + """This stream contains all posts the user is mentioned in. """ def _setlocation(self): @@ -286,7 +287,7 @@ class Mentions(Generic): class FollowedTags(Generic): - """This stream contains all posts + """This stream contains all posts containing tags the user is following. """ def _setlocation(self): @@ -298,26 +299,27 @@ class FollowedTags(Generic): :param tag_id: tag id :type tag_id: int """ - data = {'authenticity_token':self._connection.get_token()} + data = {'authenticity_token': self._connection.get_token()} request = self._connection.delete('tag_followings/{0}'.format(tag_id), data=data) if request.status_code != 404: raise Exception('wrong status code: {0}'.format(request.status_code)) def add(self, tag_name): """Follow new tag. - Error code 403 is accepted because pods respod with it when request + Error code 403 is accepted because pods respod with it when request is sent to follow a tag that a user already follows. :param tag_name: tag name :type tag_name: str :returns: int (response code) """ - data = {'name':tag_name, - 'authenticity_token':self._connection.get_token(), - } - headers={'content-type': 'application/json', - 'x-csrf-token': self._connection.get_token(), - 'accept': 'application/json'} + data = {'name': tag_name, + 'authenticity_token': self._connection.get_token(), + } + headers = {'content-type': 'application/json', + 'x-csrf-token': self._connection.get_token(), + 'accept': 'application/json' + } request = self._connection.post('tag_followings', data=json.dumps(data), headers=headers) -- 2.25.1