Fixed a non-functioning Command.set_aliases method.
This commit is contained in:
parent
a3e198e857
commit
a575942ea6
1 changed files with 9 additions and 12 deletions
|
|
@ -8,7 +8,7 @@ from builtins import range
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from evennia.locks.lockhandler import LockHandler
|
from evennia.locks.lockhandler import LockHandler
|
||||||
from evennia.utils.utils import is_iter, fill, lazy_property
|
from evennia.utils.utils import is_iter, fill, lazy_property, make_iter
|
||||||
from future.utils import with_metaclass
|
from future.utils import with_metaclass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -246,27 +246,24 @@ class Command(with_metaclass(CommandMeta, object)):
|
||||||
|
|
||||||
def set_aliases(self, new_aliases):
|
def set_aliases(self, new_aliases):
|
||||||
"""
|
"""
|
||||||
Update aliases.
|
Replace aliases with new ones.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
new_aliases (list):
|
new_aliases (str or list): Either a ;-separated string
|
||||||
|
or a list of aliases. These aliases will replace the
|
||||||
|
existing ones, if any.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
This is necessary to use to make sure the optimization
|
This is necessary to use to make sure the optimization
|
||||||
caches are properly updated as well.
|
caches are properly updated as well.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not is_iter(new_aliases):
|
if isinstance(new_aliases, basestring):
|
||||||
try:
|
new_aliases = new_aliases.split(';')
|
||||||
self.aliases = [str(alias).strip().lower()
|
aliases = (str(alias).strip().lower() for alias in make_iter(new_aliases))
|
||||||
for alias in self.aliases.split(',')]
|
self.aliases = list(set(alias for alias in aliases if alias != self.key))
|
||||||
except Exception:
|
|
||||||
self.aliases = []
|
|
||||||
self.aliases = list(set(alias for alias in self.aliases
|
|
||||||
if alias and alias != self.key))
|
|
||||||
self._optimize()
|
self._optimize()
|
||||||
|
|
||||||
|
|
||||||
def match(self, cmdname):
|
def match(self, cmdname):
|
||||||
"""
|
"""
|
||||||
This is called by the system when searching the available commands,
|
This is called by the system when searching the available commands,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue