From f54aff845b3f3c1a5325c1537c1dbd85b8951c21 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Sat, 3 Nov 2018 21:10:46 +0100 Subject: [PATCH] * Removed `backtime` parameter from `diaspy.streams.Generic()` it's `more()` method since it isn't used anymore. * Some commentary updates/cleanups here and there. --- diaspy/people.py | 37 +++++++++++++++++++++++++------------ diaspy/settings.py | 2 +- diaspy/streams.py | 7 +------ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/diaspy/people.py b/diaspy/people.py index 14a869a..cebfb92 100644 --- a/diaspy/people.py +++ b/diaspy/people.py @@ -151,13 +151,20 @@ class User(): self.data.update( data[0] ) def aspectMemberships(self): + """Returns a list with aspect memberships + + :returns: list + """ if 'contact' in self.data: return self.data.get('contact', {}).get('aspect_memberships', []) else: return self.data.get('aspect_memberships', []) def getPhotos(self): - """ + """Gets and sets this User()'s photo data. + + :returns: dict + --> GET /people/{GUID}/photos.json HTTP/1.1 <-- HTTP/1.1 200 OK @@ -221,6 +228,9 @@ class User(): def deletePhoto(self, photo_id): """ + :param photo_id: Photo ID to delete. + :type photo_id: int + --> DELETE /photos/{PHOTO_ID} HTTP/1.1 <-- HTTP/1.1 204 No Content """ @@ -261,21 +271,18 @@ class Contacts(): return self.contacts[index] def addAspect(self, name, visible=False): - """ - --> POST /aspects HTTP/1.1 - --> {"person_id":null,"name":"test","contacts_visible":false} - - <-- HTTP/1.1 200 OK - - Add new aspect. - - TODO: status_code's + """Add new aspect. :param name: aspect name to add :type name: str :param visible: sets if contacts in aspect are visible for each and other :type visible: bool :returns: JSON from request + + --> POST /aspects HTTP/1.1 + --> {"person_id":null,"name":"test","contacts_visible":false} + + <-- HTTP/1.1 200 OK """ data = { 'person_id': None, @@ -297,7 +304,11 @@ class Contacts(): return new_aspect def deleteAspect(self, aspect_id): - """ + """Deletes a aspect with given ID. + + :param aspect_id: Aspect ID to delete. + :type aspect_id: int + --> POST /aspects/{ASPECT_ID} HTTP/1.1 _method=delete&authenticity_token={TOKEN} Content-Type: application/x-www-form-urlencoded @@ -317,9 +328,9 @@ class Contacts(): :type user_id: str :param aspect_ids: list of aspect ids :type aspect_ids: list + :returns: dict """ # TODO update self.contacts - # Returns {"aspect_id":123,"person_id":123} for aid in aspect_ids: new_aspect_membership = Aspect(self._connection, aid).addUser(user_id) @@ -385,6 +396,8 @@ class Contacts(): :param set: if passed could be 'all' or 'only_sharing' :type set: str + :param page: page number to get, default 0. + :type page: int """ params = {} if set: diff --git a/diaspy/settings.py b/diaspy/settings.py index 5d7f660..53d7ab5 100644 --- a/diaspy/settings.py +++ b/diaspy/settings.py @@ -120,7 +120,7 @@ class Account(): One of the Black Magic(tm) methods. """ request = self._connection.get('user/edit') - if BS4_SUPPORT: # TODO + if BS4_SUPPORT: soup = BeautifulSoup(request.text, 'lxml') language = soup.find('select', {"id": "user_language"}) return [(option.text, option['value']) for option in language.findAll('option')] diff --git a/diaspy/streams.py b/diaspy/streams.py index 02c1ca5..5a6a95a 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -150,14 +150,9 @@ class Generic(): """ self._stream = self._obtain() - def more(self, max_time=0, backtime=86400): + def more(self, max_time=0): """Tries to download more (older posts) posts from Stream. - TODO backtime isn't used anymore. - Diaspora reference: https://github.com/diaspora/diaspora/blob/26a9e50ef935628c800f9a21d345057556fa5c31/app/helpers/stream_helper.rb#L48 - - :param backtime: how many seconds substract each time (defaults to one day) - :type backtime: int :param max_time: seconds since epoch (optional, diaspy'll figure everything on its own) :type max_time: int """ -- 2.25.1