def format_user(user, options):
    """
    Format a Bitbucket user's info into a string containing either 'Anonymous'
    or their name and links to their Bitbucket and GitHub profiles.
    """
    if user is None:
        return 'Anonymous'
    if not isinstance(user, dict):
        user = {'nickname': user, 'display_name': user}
    profile_url = 'https://bitbucket.org/{0}'.format(user['nickname'])
    if 'links' in user and 'html' in user['links'] and 'href' in user['links'][
        'html']:
        profile_url = user['links']['html']['href']
    bb_user = 'Bitbucket: [{0}]({1})'.format(user['nickname'], profile_url)
    if user['nickname'] in options.settings['bb_gh_user_mapping']:
        gh_username = options.settings['bb_gh_user_mapping'][user['nickname']]
        gh_user = ', GitHub: [{0}](https://github.com/{0})'.format(gh_username)
    else:
        gh_user = ''
    return user['display_name'] + ' (' + bb_user + gh_user + ')'
