Add provider_display_name to posts
[diaspy.git] / diaspy / search.py
1 #!/usr/bin/env python3
2
3 """This module holds functionality related to searching.
4 """
5
6
7 class Search():
8 """This object is used for searching for content on Diaspora*.
9 """
10 def __init__(self, connection):
11 self._connection = connection
12
13 def lookupUser(self, handle):
14 """This function will launch a webfinger lookup from the pod for the
15 handle requested. Response code is returned and if the lookup was successful,
16 user should soon be searchable via pod used for connection.
17
18 :param string: Handle to search for.
19 """
20 request = self._connection.get('people', headers={'accept': 'text/html'}, params={'q': handle})
21 return request.status_code
22
23 def user(self, query):
24 """Searches for a user.
25 Will return list of dictionaries containing
26 data of found users.
27 """
28 request = self._connection.get('people.json', params={'q': query, 'utf-8': '%u2713'})
29 if request.status_code == 200:
30 result = request.json()
31 else:
32 raise errors.SearchError('wrong status code: {0}'.format(request.status_code))
33 return result