def slugify_username(value): """Clean up username. This is based on Django slugify with exception of lowercasing - Converts to ascii - Removes not wanted chars - Merges whitespaces and - into single - """ value = (unicodedata.normalize("NFKD", force_str(value)).encode( "ascii", "ignore").decode("ascii")) # Return username if it matches our standards if USERNAME_MATCHER.match(value): return value value = STRIP_MATCHER.sub("", value).strip().lstrip(".") return CLEANUP_MATCHER.sub("-", value)
def slugify_username(value): """Clean up username This is based on Django slugify with exception of lowercasing - Converts to ascii - Removes not wanted chars - Merges whitespaces and - into single - """ value = unicodedata.normalize('NFKD', force_text(value)).encode( 'ascii', 'ignore').decode('ascii') # Return username if it matches our standards if USERNAME_MATCHER.match(value): return value value = STRIP_MATCHER.sub('', value).strip().lstrip('.') return CLEANUP_MATCHER.sub('-', value)
def slugify_username(value): """Clean up username This is based on Django slugify with exception of lowercasing - Converts to ascii - Removes not wanted chars - Merges whitespaces and - into single - """ value = unicodedata.normalize( 'NFKD', force_text(value) ).encode( 'ascii', 'ignore' ).decode('ascii') # Return username if it matches our standards if USERNAME_MATCHER.match(value): return value value = STRIP_MATCHER.sub('', value).strip().lstrip('.') return CLEANUP_MATCHER.sub('-', value)