Switch unidecode over to the new anunidecode library and write some tests to validate results.
This commit is contained in:
parent
2d21dc9293
commit
09917ff062
4 changed files with 54 additions and 5 deletions
|
@ -1,7 +1,6 @@
|
|||
import re
|
||||
import string
|
||||
|
||||
from unidecode import unidecode
|
||||
import anunidecode
|
||||
|
||||
|
||||
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
|
||||
|
@ -49,7 +48,7 @@ def _gen_filler_chars(num_filler_chars):
|
|||
|
||||
|
||||
def generate_valid_usernames(input_username):
|
||||
normalized = unidecode(input_username).strip().lower()
|
||||
normalized = input_username.encode('unidecode', 'ignore').strip().lower()
|
||||
prefix = re.sub(INVALID_USERNAME_CHARACTERS, '_', normalized)[:30]
|
||||
|
||||
num_filler_chars = max(0, MIN_LENGTH - len(prefix))
|
||||
|
|
Reference in a new issue