Parse usernames.
17885
def _parse_users(self, match):
        ''''''

        # Don't parse lists here
        if match.group(2) is not None:
            return match.group(0)

        mat = match.group(0)
        if self._include_spans:
            self._users.append((mat[1:], match.span(0)))
        else:
            self._users.append(mat[1:])

        if self._html:
            return self.format_username(mat[0:1], mat[1:])
490743
def valid_username(user):
    '''
    
    '''
    if not isinstance(user, six.string_types):
        return False

    if len(user) > 32:
        return False

    return VALID_USERNAME.match(user) is not None
152949
def get_by_username(cls, username):
        
        return cls.query.filter(
            UserProfile._username == username.lower()
        ).one()
923039
def user_parse(data):
        """"""
        id_ = data.get('id')
        yield 'id', id_
        yield 'email', data.get('email')
        yield 'first_name', data.get('first_name')
        yield 'last_name', data.get('last_name')
        yield 'username', data.get('name')
        yield 'picture', 'http://graph.facebook.com/{0}/picture?' \
                         'type=large'.format(id_)
        yield 'link', data.get('link')
        yield 'locale', data.get('locale')
        yield 'gender', data.get('gender')

        location = data.get('location', {}).get('name')
        if location:
            split_location = location.split(', ')
            yield 'city', split_location[0].strip()
            if len(split_location) > 1:
                yield 'country', split_location[1].strip()
167646
def people_findByUsername(username):
    """"""
    method = 'flickr.people.findByUsername'
    data = _doget(method, username=username)
    user = User(data.rsp.user.id, username=data.rsp.user.username.text)
    return user
575748
def usernames(urls):
    '''

    '''
    usernames = StringCounter()
    for url, count in urls.items():
        uparse = urlparse(url)
        path = uparse.path
        hostname = uparse.hostname
        m = username_re.match(path)
        if m:
            usernames[m.group('username')] += count
        elif hostname in ['twitter.com', 'www.facebook.com']:
            usernames[path.lstrip('/')] += count
    return usernames
732438
def clean_username(self, username, shallow=False):
        
        for validator in app_settings.USERNAME_VALIDATORS:
            validator(username)

        # TODO: Add regexp support to USERNAME_BLACKLIST
        username_blacklist_lower = [ub.lower()
                                    for ub in app_settings.USERNAME_BLACKLIST]
        if username.lower() in username_blacklist_lower:
            raise forms.ValidationError(
                self.error_messages['username_blacklisted'])
        # Skipping database lookups when shallow is True, needed for unique
        # username generation.
        if not shallow:
            from .utils import filter_users_by_username
            if filter_users_by_username(username).exists():
                user_model = get_user_model()
                username_field = app_settings.USER_MODEL_USERNAME_FIELD
                error_message = user_model._meta.get_field(
                    username_field).error_messages.get('unique')
                if not error_message:
                    error_message = self.error_messages['username_taken']
                raise forms.ValidationError(
                    error_message,
                    params={
                        'model_name': user_model.__name__,
                        'field_label': username_field,
                    }
                )
        return username
821707
def username(self, value):
        
        self._username = value
        self._connectionXML.set('username', value)
813753
def name(username):
    """"""
    if not username:
        click.secho(dtool_config.utils.get_username(CONFIG_PATH))
    else:
        username_str = " ".join(username)
        click.secho(dtool_config.utils.set_username(CONFIG_PATH, username_str))
489628
def get_username(self):
        """"""
        _from = self.auth_context['from']
        if self.token_version == 1:
            return '{0}'.format(_from)
        elif self.token_version == 2:
            _user_type = self.auth_context['user_type']
            return '{0}/{1}/{2}'.format(
                self.token_version,
                _user_type,
                _from
            )
165837
def get_user_variables(self):
        """'"""
        # TODO: Check if some user fields are stored in other content_trees
        return [
            e.get('{%s}name' % e.nsmap.get('text'))[5:]
            for e in get_user_fields(self.content_trees[0], self.namespaces)
        ]
544139
def __verify_username(self, username):
        """"""

        if len(username) > self.__max_length or len(username) < 3:
            raise ValueError(
                f"Username must be between 3 and {self.__max_length} characters."
            )
        if any(c not in string.ascii_letters + string.digits for c in username):
            raise ValueError("Usernames can only contain alphanumeric characters.")
777121
def get_username(identifier):
    """"""
    pattern = re.compile('.+@\w+\..+')
    if pattern.match(identifier):
        try:
            user = User.objects.get(email=identifier)
        except:
            raise Http404
        else:
            return user.username
    else:
        return identifier
338395
private static String checkUsername(String username) {
        if (username.length() < 3) {
            return "too short (minimum: 3 characters)";
        } else if (username.length() > 64) {
            return "too long (maximum: 64 characters)";
        }

        for (int i = 0; i < username.length(); i++) {
            char c = username.charAt(i);
            if (c >= 'A' && c <= 'Z') continue;
            if (c >= 'a' && c <= 'z') continue;
            if (c >= '0' && c <= '9') continue;
            if (c == '_') continue;
            return "invalid character at position " + (i+1) + ": " + jq(""+c);
        }

        return null;
    }
65761
function parseUserlistEntry(nickWithFlags) {
	const userlistEntry = new UserlistEntry();
	for (let i of indices(nickWithFlags.length)) {
		switch (nickWithFlags.charAt(i)) {
			case '~':
				userlistEntry.owner = true;
				break;
			case '&':
				userlistEntry.admin = true;
				break;
			case '@':
				userlistEntry.op = true;
				break;
			case '%':
				userlistEntry.halfop = true;
				break;
			case '+':
				userlistEntry.voice = true;
				break;
			default:
				userlistEntry.nick = nickWithFlags.substring(i);
				return userlistEntry;
		}
	}

	// if here, we got an empty name
	return null;
}
62277
def parse_names(cls, names: List[str]) -> T:
        """"""
        value = 0
        iterable = cls  # type: Iterable
        for name in names:
            name = name.lower()
            flag = next((item for item in iterable if name == item.name.lower()), None)
            if not flag:
                raise ValueError("{} is not a member of {}".format(
                    name, cls.__name__))
            value = value | int(flag)
        return cls(value)
1151699
def chain_user_names(users, exclude_user, truncate=35):
    """"""
    if not users or not isinstance(exclude_user, get_user_model()):
        return ''
    return truncatechars(
        ', '.join(u'{}'.format(u) for u in users.exclude(pk=exclude_user.pk)),
        truncate)