* __bug__: `diaspy` has problems/can't connect to pods using SNI (this is an issue with requests/urllib3/python),
+----
+
+#### Version `0.4.3`:
+
+* __new__: `people.User().fetchprofile()` will issue a warning when user cannot be found on current pod,
+* __new__: `settings.Profile` is now loaded during initialization (can be switched off),
+
+* __fix__: fixed a bug in `__repr__()` method in `people.User()` object,
+
+
----
#### Version `0.4.2` (2013-12-19):
import json
import re
+import warnings
+
from diaspy.streams import Outer
from diaspy.models import Aspect
from diaspy import errors
return self['guid']
def __repr__(self):
- return '{0} ({1})'.format(self['diaspora_name'], self['guid'])
+ return '{0} ({1})'.format(self['name'], self['guid'])
def _fetchstream(self):
self.stream = Outer(self._connection, location='people/{0}.json'.format(self['guid']))
def fetchprofile(self):
"""Fetches user data.
"""
- data = search.Search(self._connection).user(self['handle'])[0]
- self.data = data
+ data = search.Search(self._connection).user(self['handle'])
+ if not data:
+ warnings.warn('user with handle "{0}" has not been found on pod "{1}"'.format(self['handle'], self._connection.pod))
+ else:
+ self.data = data[0]
def getHCard(self):
"""Returns XML string containing user HCard.
"""Provides interface to account settings.
"""
email_regexp = re.compile('<input id="user_email" name="user\[email\]" size="30" type="text" value="(.+?)"')
- language_option_regexp = re.compile('<option value="([-_a-z]+)">(.*?)</option>')
+ language_option_regexp = re.compile('<option value="([_a-zA-Z-]+)"(?: selected="selected")?>(.*?)</option>')
def __init__(self, connection):
self._connection = connection
is_searchable_regexp = re.compile('checked="checked" id="profile_searchable" name="profile\[searchable\]" type="checkbox" value="(.*?)" />')
is_nsfw_regexp = re.compile('checked="checked" id="profile_nsfw" name="profile\[nsfw\]" type="checkbox" value="(.*?)" />')
- def __init__(self, connection):
+ def __init__(self, connection, no_load=False):
self._connection = connection
self.data = {'utf-8': '✓',
'_method': 'put',
}
self._html = self._fetchhtml()
self._loaded = False
+ if not no_load: self.load()
def _fetchhtml(self):
"""Fetches html that will be used to extract data.
self.assertIn('avatar', user.data)
self.assertEqual(type(user.stream), diaspy.streams.Outer)
+ def testReprMethod(self):
+ user = diaspy.people.User(test_connection, guid=testconf.guid)
+ repr(user)
+ print(user)
+
class ContactsTest(unittest.TestCase):
def testGetOnlySharing(self):