'Retrieves a user\'s bookmarks from Delicious.com.
If a correct username AND password are supplied, a user\'s *full*
bookmark collection (which also includes private bookmarks) is
retrieved. Data communication is encrypted using SSL in this case.
If no password is supplied, only the *public* bookmarks of the user
are retrieved. Here, the parameter \'max_bookmarks\' specifies how
many public bookmarks will be retrieved (default: 50). Set the
parameter to 0 to retrieve all public bookmarks.
This function can be used to backup all of a user\'s bookmarks if
called with a username and password.
@param username: The Delicious.com username.
@type username: str
@param password: Optional, default: None.
The user\'s Delicious.com password. If password is set,
all communication with Delicious.com is SSL-encrypted.
@type password: unicode/str
@param max_bookmarks: Optional, default: 50.
See the documentation of get_bookmarks() for more
information as get_url() uses get_bookmarks() to
retrieve a url\'s bookmarking history.
The parameter is NOT used when a password is specified
because in this case the *full* bookmark collection of
a user will be retrieved.
@type max_bookmarks: int
@param sleep_seconds: Optional, default: 1.
See the documentation of get_bookmarks() for more information as
get_url() uses get_bookmarks() to retrieve a url\'s bookmarking
history. sleep_seconds must be >= 1 to comply with Delicious.com\'s
Terms of Use.
@type sleep_seconds: int
@return: DeliciousUser instance'

def get_user(self, username, password=None, max_bookmarks=50, sleep_seconds=1):

    assert username
    user = DeliciousUser(username)
    bookmarks = []
    if password:
        path = '/v1/posts/all'
        data = self._query(path, host='api.del.icio.us', use_ssl=True, user=username, password=password)
        if data:
            soup = BeautifulSoup(data)
            elements = soup.findAll('post')
            for element in elements:
                url = element['href']
                title = (element['description'] or u'')
                comment = (element['extended'] or u'')
                tags = []
                if element['tag']:
                    tags = element['tag'].split()
                timestamp = datetime.datetime.strptime(element['time'], '%Y-%m-%dT%H:%M:%SZ')
                bookmarks.append((url, tags, title, comment, timestamp))
        user.bookmarks = bookmarks
    elif ((max_bookmarks > 0) and (max_bookmarks <= 100)):
        path = ('/v2/json/%s?count=%d' % (username, max_bookmarks))
        data = self._query(path, host='feeds.delicious.com', user=username)
        if data:
            posts = []
            try:
                posts = simplejson.loads(data)
            except TypeError:
                pass
            url = timestamp = None
            title = comment = u''
            tags = []
            for post in posts:
                try:
                    url = post['u']
                except KeyError:
                    pass
                try:
                    title = post['d']
                except KeyError:
                    pass
                try:
                    tags = post['t']
                except KeyError:
                    pass
                if (not tags):
                    tags = [u'system:unfiled']
                try:
                    comment = post['n']
                except KeyError:
                    pass
                try:
                    timestamp = datetime.datetime.strptime(post['dt'], '%Y-%m-%dT%H:%M:%SZ')
                except KeyError:
                    pass
                bookmarks.append((url, tags, title, comment, timestamp))
            user.bookmarks = bookmarks[:max_bookmarks]
    else:
        user.bookmarks = self.get_bookmarks(username=username, max_bookmarks=max_bookmarks, sleep_seconds=sleep_seconds)
    return user
