Clarified output of utils.string_from_module. See #541.

This commit is contained in:
Griatch 2014-08-15 23:40:16 +02:00
parent 42d614dc0e
commit 5750f407df
2 changed files with 10 additions and 10 deletions

View file

@ -297,7 +297,7 @@ class CmdUnloggedinQuit(Command):
# The login menu tree, using the commands above # The login menu tree, using the commands above
START = MenuNode("START", text=utils.string_from_module(CONNECTION_SCREEN_MODULE), START = MenuNode("START", text=utils.random_string_from_module(CONNECTION_SCREEN_MODULE),
links=["node1a", "node2a", "node3", "END"], links=["node1a", "node2a", "node3", "END"],
linktexts=["Log in with an existing account", linktexts=["Log in with an existing account",
"Create a new account", "Create a new account",

View file

@ -844,12 +844,15 @@ def string_from_module(module, variable=None, default=None):
""" """
This is a wrapper for variable_from_module that requires return This is a wrapper for variable_from_module that requires return
value to be a string to pass. It's primarily used by login screen. value to be a string to pass. It's primarily used by login screen.
if variable is not set, returns a list of all string variables in
module
""" """
val = variable_from_module(module, variable=variable, default=default) val = variable_from_module(module, variable=variable, default=default)
if isinstance(val, basestring): if val:
if variable:
return val return val
elif is_iter(val): else:
result = [v for v in val if isinstance(v, basestring)] result = [v for v in make_iter(val) if isinstance(v, basestring)]
return result if result else default return result if result else default
return default return default
@ -857,10 +860,7 @@ def random_string_from_module(module):
""" """
Returns a random global string from a module Returns a random global string from a module
""" """
string = string_from_module(module) return random.choice(string_from_module(module))
if is_iter(string):
string = random.choice(string)
return string
def init_new_player(player): def init_new_player(player):
""" """