Switch unidecode over to the new anunidecode library and write some tests to validate results.

This commit is contained in:
Jake Moshenko 2014-08-01 15:50:25 -04:00
parent 2d21dc9293
commit 09917ff062
4 changed files with 54 additions and 5 deletions

View file

@ -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))