pass
+class SearchError(DiaspyError):
++ """Exception raised when something related to search goes wrong.
++ """
++ pass
++
++
+ class ConversationError(DiaspyError):
+ """Exception raised when something related to conversations goes wrong.
+ """
+ pass
+
+
+ class AspectError(DiaspyError):
+ """Exception raised when something related to aspects goes wrong.
+ """
+ pass
+
+
+ class PostError(DiaspyError):
+ """Exception raised when something related to posts goes wrong.
+ """
+ pass
+
+
+ class StreamError(DiaspyError):
+ """Exception raised when something related to streams goes wrong.
+ """
pass
optional parameters. GUID takes precedence over handle when fetching
user stream. When fetching user data, handle is required.
"""
- data = {}
- stream = []
-
def __init__(self, connection, guid='', handle='', fetch='posts', id=0):
self._connection = connection
+ self.stream = []
+ self.handle = handle
+ self.guid = guid
self.data = {
'guid': guid,
'handle': handle,
def fetchguid(self):
"""Fetch user data and posts using guid.
"""
- request = self._connection.get('people/{0}.json'.format(self['guid']))
+ request = self._connection.get('people/{0}.json'.format(self.guid))
self._postproc(request)
- def fetchprofile(self, protocol='https'):
- """Fetch user data using Diaspora handle.
- """
- request = self._connection.get('people.json?q={0}'.format(self['handle']))
- if request.status_code != 200:
- raise Exception('wrong error code: {0}'.format(request.status_code))
- else:
- request = request.json()
- if len(request):
- names = [('id', 'id'),
- ('handle', 'diaspora_id'),
- ('guid', 'guid'),
- ('name', 'diaspora_name'),
- ('avatar', 'image_urls'),
- ]
- self.data = self._finalize_data(request[0], names)
-
class Contacts():
"""This class represents user's list of contacts.