mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Handle missing account in Command
This commit is contained in:
parent
3d8e81e0b4
commit
14501db8de
1 changed files with 22 additions and 6 deletions
|
|
@ -623,6 +623,22 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th
|
|||
)[0]
|
||||
return settings.CLIENT_DEFAULT_WIDTH
|
||||
|
||||
def _get_account_option(self, option):
|
||||
"""
|
||||
Retrieve the value of a specified account option.
|
||||
|
||||
Args:
|
||||
option (str): The name of the option to retrieve.
|
||||
|
||||
Returns:
|
||||
The value of the specified account option if the account exists,
|
||||
otherwise the default value from settings.OPTIONS_ACCOUNT_DEFAULT.
|
||||
|
||||
"""
|
||||
if self.account:
|
||||
return self.account.options.get(option)
|
||||
return settings.OPTIONS_ACCOUNT_DEFAULT.get(option)
|
||||
|
||||
def styled_table(self, *args, **kwargs):
|
||||
"""
|
||||
Create an EvTable styled by on user preferences.
|
||||
|
|
@ -638,8 +654,8 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th
|
|||
or incomplete and ready for use with `.add_row` or `.add_collumn`.
|
||||
|
||||
"""
|
||||
border_color = self.account.options.get("border_color")
|
||||
column_color = self.account.options.get("column_names_color")
|
||||
border_color = self._get_account_option("border_color")
|
||||
column_color = self._get_account_option("column_names_color")
|
||||
|
||||
colornames = ["|%s%s|n" % (column_color, col) for col in args]
|
||||
|
||||
|
|
@ -699,9 +715,9 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th
|
|||
"""
|
||||
|
||||
colors = dict()
|
||||
colors["border"] = self.account.options.get("border_color")
|
||||
colors["headertext"] = self.account.options.get("%s_text_color" % mode)
|
||||
colors["headerstar"] = self.account.options.get("%s_star_color" % mode)
|
||||
colors["border"] = self._get_account_option("border_color")
|
||||
colors["headertext"] = self._get_account_option("%s_text_color" % mode)
|
||||
colors["headerstar"] = self._get_account_option("%s_star_color" % mode)
|
||||
|
||||
width = width or self.client_width()
|
||||
if edge_character:
|
||||
|
|
@ -722,7 +738,7 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th
|
|||
else:
|
||||
center_string = ""
|
||||
|
||||
fill_character = self.account.options.get("%s_fill" % mode)
|
||||
fill_character = self._get_account_option("%s_fill" % mode)
|
||||
|
||||
remain_fill = width - len(center_string)
|
||||
if remain_fill % 2 == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue