<s> from __future__ import unicode_literals <EOL> import re <EOL> from . reserved_words import get_reserved_wordlist <EOL> username_regex = re . compile ( r"""<STR_LIT>""" , re . X ) <EOL> def is_safe_username ( username , whitelist = None , blacklist = None , <EOL> regex = username_regex ) : <EOL> if not re . match ( regex , username ) : <EOL> return False <EOL> wordlist = get_reserved_wordlist ( ) <EOL> whitelist = whitelist or set ( ) <EOL> blacklist = blacklist or set ( ) <EOL> wordlist = wordlist - whitelist <EOL> wordlist = wordlist . union ( blacklist ) <EOL> return False if username . lower ( ) in wordlist else True </s>
