* Apparently `/u/username.json` retuns 404 so `diaspy.people.User().fetchhandle()` now fetches data using `diaspy.people.User().fetchprofile()`.
* Some formatting fixes in `settings.py`
* `tests.py` should succeed now.
* __upd__: Update `diaspy.models.Post()` it's interaction data after liked,
* __upd__: `diaspy.connection.Connection()`'s `getUserData()` method will now set the `Connection()` object it's `self._userdata`,
* __upd__: Posts obtained by `diaspy.streams.Generic()` are now fetched once instead of twice,
+* __upd__: `tests.py`,
* __fix__: Streams seemed to miss posts on `more()` method, should be fixed now. Also a new dependency: `dateutil`,
* __rem__: `_obtain()` from `diaspy.streams.Outer()`, it was the same as `_obtain()` in `diaspy.streams.Generic()`,
* __rem__: `diaspy.models.Post()` its `update()` method since it is deprecated for a while now,
-* __rem__: `backtime` parameter removed from `diaspy.streams.Generic.more()`.
+* __rem__: `backtime` parameter removed from `diaspy.streams.Generic.more()`,
+* __rem__: `protocol` parameter removed from `diaspy.people.User().fetchhandle()`.
----
self.stream = []
self.data = {
'guid': guid,
- 'handle': handle,
+ 'diaspora_id': handle,
'id': id,
}
self.photos = []
return '{0} ({1})'.format(self.handle(), self.guid())
def handle(self):
- if 'handle' in self.data: return self['handle']
- return self.data.get('diaspora_id', 'Unknown handle')
+ return self.data.get('diaspora_id', 'Unknown Diaspora ID')
def guid(self):
return self.data.get('guid', '<guid missing>')
if fetch == 'posts':
if self.handle() and not self['guid']: self.fetchhandle()
else: self.fetchguid()
- elif fetch == 'data' and self['handle']:
+ elif fetch == 'data' and self['diaspora_id']:
self.fetchprofile()
def _finalize_data(self, data):
"""
if request.status_code != 200: raise Exception('wrong error code: {0}'.format(request.status_code))
data = request.json()
- self.data = self._finalize_data(data)
+ self.data.update(self._finalize_data(data))
- def fetchhandle(self, protocol='https'):
- """Fetch user data and posts using Diaspora handle.
+ def fetchhandle(self):
+ """Fetch user data and posts using Diaspora ID (previously known as handle).
"""
- pod, user = sephandle(self['handle'])
- request = self._connection.get('{0}://{1}/u/{2}.json'.format(protocol, pod, user), direct=True)
- self._postproc(request)
+ self.fetchprofile()
self._fetchstream()
def fetchguid(self, fetch_stream=True):
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')]
+ return [(option['value'], option.text) for option in language.findAll('option')]
else:
return self.language_option_regexp.findall(request.text)
else: month_option = -1
elif named_month:
month_option = month_option.text
- else: month_option = month_option['value']
+ else: month_option = int(month_option['value'])
day = soup.find('select', {"id": "profile_date_day"})
day_option = day.find('option', selected=True)
def testGettingUserByHandlePosts(self):
user = diaspy.people.User(test_connection, handle=testconf.diaspora_id)
self.assertEqual(testconf.guid, user['guid'])
- self.assertEqual(testconf.diaspora_id, user['handle'])
+ self.assertEqual(testconf.diaspora_id, user['diaspora_id'])
self.assertEqual(testconf.diaspora_name, user['name'])
self.assertIn('id', user.data)
self.assertIn('avatar', user.data)
def testGettingUserByGUID(self):
user = diaspy.people.User(test_connection, guid=testconf.guid)
- self.assertEqual(testconf.diaspora_id, user['handle'])
+ self.assertEqual(testconf.diaspora_id, user['diaspora_id'])
self.assertEqual(testconf.diaspora_name, user['name'])
self.assertIn('id', user.data)
- self.assertIn('avatar', user.data)
+ self.assertIn('avatar', user.data['profile'])
self.assertEqual(type(user.stream), diaspy.streams.Outer)
def testReprMethod(self):