diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 2b0b14ffc3..5ce0f44d12 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -53,6 +53,7 @@ __all__ = ( # used by set from ast import literal_eval as _LITERAL_EVAL +LIST_APPEND_CHAR = '+' # used by find CHAR_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS @@ -1648,7 +1649,9 @@ class CmdSetAttribute(ObjManipCommand): val = val.strip('[]') if val[0] in quotes: return val.strip(quotes) - + if val[0] == LIST_APPEND_CHAR: + # List insert/append syntax + return val try: return int(val) except ValueError: @@ -1720,7 +1723,7 @@ class CmdSetAttribute(ObjManipCommand): # a key that starts with @ will insert a new item at that # location, and move the other elements down. # Just '@' will append to the list - if isinstance(acc_key, str) and acc_key[0] == '@': + if isinstance(acc_key, str) and acc_key[0] == LIST_APPEND_CHAR: try: if len(acc_key) > 1: where = int(acc_key[1:]) diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 7444ddb086..478633d8fe 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -553,9 +553,9 @@ class TestBuilding(CommandTest): "Obj/test1[5] =", "Obj has no attribute 'test1[5]'.") # Append self.call(building.CmdSetAttribute(), - "Obj/test1[@] = 42", "Modified attribute Obj/test1 = [2, 42]") + "Obj/test1[+] = 42", "Modified attribute Obj/test1 = [2, 42]") self.call(building.CmdSetAttribute(), - "Obj/test1[@0] = -1", "Modified attribute Obj/test1 = [-1, 2, 42]") + "Obj/test1[+0] = -1", "Modified attribute Obj/test1 = [-1, 2, 42]") # dict - removing white space proves real parsing self.call(building.CmdSetAttribute(), @@ -578,19 +578,19 @@ class TestBuilding(CommandTest): self.call(building.CmdSetAttribute(), "Obj/test2['five'] =", "Obj has no attribute 'test2['five']'.") self.call(building.CmdSetAttribute(), - "Obj/test2[@]=42", "Modified attribute Obj/test2 = {'one': 99, 'three': 3, '@': 42}") + "Obj/test2[+]=42", "Modified attribute Obj/test2 = {'one': 99, 'three': 3, '+': 42}") self.call(building.CmdSetAttribute(), - "Obj/test2[@1]=33", - "Modified attribute Obj/test2 = {'one': 99, 'three': 3, '@': 42, '@1': 33}") + "Obj/test2[+1]=33", + "Modified attribute Obj/test2 = {'one': 99, 'three': 3, '+': 42, '+1': 33}") # tuple self.call(building.CmdSetAttribute(), "Obj/tup = (1,2)", "Created attribute Obj/tup = (1, 2)") self.call(building.CmdSetAttribute(), "Obj/tup[1] = 99", "'tuple' object does not support item assignment - (1, 2)") self.call(building.CmdSetAttribute(), - "Obj/tup[@] = 99", "'tuple' object does not support item assignment - (1, 2)") + "Obj/tup[+] = 99", "'tuple' object does not support item assignment - (1, 2)") self.call(building.CmdSetAttribute(), - "Obj/tup[@1] = 99", "'tuple' object does not support item assignment - (1, 2)") + "Obj/tup[+1] = 99", "'tuple' object does not support item assignment - (1, 2)") self.call(building.CmdSetAttribute(), # Special case for tuple, could have a better message "Obj/tup[1] = ", "Obj has no attribute 'tup[1]'.")