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
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"],
linktexts=["Log in with an existing account",
"Create a new account",

View file

@ -844,23 +844,23 @@ def string_from_module(module, variable=None, default=None):
"""
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.
if variable is not set, returns a list of all string variables in
module
"""
val = variable_from_module(module, variable=variable, default=default)
if isinstance(val, basestring):
return val
elif is_iter(val):
result = [v for v in val if isinstance(v, basestring)]
return result if result else default
if val:
if variable:
return val
else:
result = [v for v in make_iter(val) if isinstance(v, basestring)]
return result if result else default
return default
def random_string_from_module(module):
"""
Returns a random global string from a module
"""
string = string_from_module(module)
if is_iter(string):
string = random.choice(string)
return string
return random.choice(string_from_module(module))
def init_new_player(player):
"""