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
: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)
http://pad.spored.de/ro/r.qWmvhSZg7rk4OQam
"""
+
class Generic:
"""Object representing generic stream. Used in Tag(),
Stream(), Activity() etc.
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):
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):
class Commented(Generic):
- """This stream contains all posts
+ """This stream contains all posts
the user has made a comment on.
"""
def _setlocation(self):
class Mentions(Generic):
- """This stream contains all posts
+ """This stream contains all posts
the user is mentioned in.
"""
def _setlocation(self):
class FollowedTags(Generic):
- """This stream contains all posts
+ """This stream contains all posts
containing tags the user is following.
"""
def _setlocation(self):
: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)