def get_default_username(check_db=True):
    """
    Try to determine the current system user's username to use as a default.

    :param check_db: If ``True``, requires that the username does not match an
        existing ``auth.User`` (otherwise returns an empty string).
    :returns: The username, or an empty string if no username can be
        determined.
    """
    from django.contrib.auth.management.commands.createsuperuser import (
        RE_VALID_USERNAME)
    default_username = get_system_username()
    try:
        default_username = unicodedata.normalize('NFKD', default_username)\
            .encode('ascii', 'ignore').replace(' ', '').lower()
    except UnicodeDecodeError:
        return ''
    if not RE_VALID_USERNAME.match(default_username):
        return ''
    # Don't return the default username if it is already taken.
    if check_db and default_username:
        try:
            User.objects.get(username=default_username)
        except User.DoesNotExist:
            pass
        else:
            return ''
    return default_username
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/contrib/auth/management/__init__.py/get_default_username/original