def create_username(caller, string_input):
 menutree = caller.ndb._menutree
 string_input = string_input.strip()
 player = managers.players.get_player_from_name(string_input)
 if player:
  text = dedent('\n            |rThe account {} already exists.|n\n            Enter another username or leave blank to go back.\n        '.strip('\n')).format(string_input)
  options = ({'key': '', 'goto': 'start'}, {'key': '_default', 'goto': 'create_username'})
 elif (not RE_VALID_USERNAME.search(string_input)):
  text = dedent("\n            |rThis username isn't valid.|n\n            Only letters are accepted, without special characters.\n            The username must be at least 3 characters long.\n            Enter another username or leave blank to go back.\n        ".strip('\n'))
  options = ({'key': '', 'goto': 'start'}, {'key': '_default', 'goto': 'create_username'})
 else:
  menutree.playername = string_input
  caller.msg('', options={'echo': False})
  text = "Enter this account's new password."
  options = ({'key': '_default', 'goto': 'create_password'},)
 return (text, options)

def create_username ( caller , string_input ) : menutree = caller . ndb . _menutree string_input = string_input . strip ( ) player = managers . players . get_player_from_name ( string_input ) if player : text = dedent ( '\n            |rThe account {} already exists.|n\n            Enter another username or leave blank to go back.\n        ' . strip ( '\n' ) ) . format ( string_input ) options = ( { 'key' : '' , 'goto' : 'start' } , { 'key' : '_default' , 'goto' : 'create_username' } ) elif ( not RE_VALID_USERNAME . search ( string_input ) ) : text = dedent ( "\n            |rThis username isn't valid.|n\n            Only letters are accepted, without special characters.\n            The username must be at least 3 characters long.\n            Enter another username or leave blank to go back.\n        " . strip ( '\n' ) ) options = ( { 'key' : '' , 'goto' : 'start' } , { 'key' : '_default' , 'goto' : 'create_username' } ) else : menutree . playername = string_input caller . msg ( '' , options = { 'echo' : False } ) text = "Enter this account's new password." options = ( { 'key' : '_default' , 'goto' : 'create_password' } , ) return ( text , options )
prompt to enter a valid username .