mirror of
https://github.com/evennia/evennia.git
synced 2025-10-29 11:26:10 +00:00
Resolve merge conflicts
This commit is contained in:
commit
cc5aa91be1
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
# This is used with `make <option>` and is used for running various
|
||||
# administration operations on the code.
|
||||
|
||||
BLACK_FORMAT_CONFIGS = --target-version py37 --line-length 100
|
||||
BLACK_FORMAT_CONFIGS = --target-version py37 --line-length 100 --exclude=/docs
|
||||
TEST_GAME_DIR = .test_game_dir
|
||||
TESTS ?= evennia
|
||||
|
||||
|
||||
@ -13,8 +13,9 @@ from evennia.utils.utils import (
|
||||
class_from_module,
|
||||
get_all_typeclasses,
|
||||
variable_from_module,
|
||||
dbref, interactive,
|
||||
list_to_string
|
||||
dbref,
|
||||
interactive,
|
||||
list_to_string,
|
||||
)
|
||||
from evennia.utils.eveditor import EvEditor
|
||||
from evennia.utils.evmore import EvMore
|
||||
@ -3230,7 +3231,6 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
||||
# helper functions for spawn
|
||||
|
||||
|
||||
|
||||
class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
"""
|
||||
spawn objects from prototype
|
||||
@ -3341,8 +3341,8 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
# we have a single prototype, check access
|
||||
prototype = prototypes[0]
|
||||
if not self.caller.locks.check_lockstring(
|
||||
self.caller, prototype.get("prototype_locks", ""),
|
||||
access_type="spawn", default=True):
|
||||
self.caller, prototype.get("prototype_locks", ""), access_type="spawn", default=True
|
||||
):
|
||||
err = "You don't have access to use this prototype."
|
||||
|
||||
if err:
|
||||
@ -3440,10 +3440,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
if not table:
|
||||
return True
|
||||
EvMore(
|
||||
self.caller,
|
||||
str(table),
|
||||
exit_on_lastpage=True,
|
||||
justify_kwargs=False,
|
||||
self.caller, str(table), exit_on_lastpage=True, justify_kwargs=False,
|
||||
)
|
||||
|
||||
@interactive
|
||||
@ -3487,7 +3484,8 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
return
|
||||
try:
|
||||
n_updated = spawner.batch_update_objects_with_prototype(
|
||||
prototype, objects=existing_objects)
|
||||
prototype, objects=existing_objects
|
||||
)
|
||||
except Exception:
|
||||
logger.log_trace()
|
||||
caller.msg(f"{n_updated} objects were updated.")
|
||||
@ -3575,8 +3573,11 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
tags = self.lhslist
|
||||
err = self._list_prototypes(tags=tags)
|
||||
if err:
|
||||
caller.msg("No prototypes found with prototype-tag(s): {}".format(
|
||||
list_to_string(tags, "or")))
|
||||
caller.msg(
|
||||
"No prototypes found with prototype-tag(s): {}".format(
|
||||
list_to_string(tags, "or")
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
if "save" in self.switches:
|
||||
@ -3606,8 +3607,10 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
prot_prototype_key = prototype.get("prototype_key")
|
||||
|
||||
if not (prototype_key or prot_prototype_key):
|
||||
caller.msg("A prototype_key must be given, either as `prototype_key = <prototype>` "
|
||||
"or as a key 'prototype_key' inside the prototype structure.")
|
||||
caller.msg(
|
||||
"A prototype_key must be given, either as `prototype_key = <prototype>` "
|
||||
"or as a key 'prototype_key' inside the prototype structure."
|
||||
)
|
||||
return
|
||||
|
||||
if prototype_key is None:
|
||||
@ -3615,14 +3618,14 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
|
||||
if prot_prototype_key != prototype_key:
|
||||
caller.msg("(Replacing `prototype_key` in prototype with given key.)")
|
||||
prototype['prototype_key'] = prototype_key
|
||||
prototype["prototype_key"] = prototype_key
|
||||
|
||||
if prototype_desc is not None and prot_prototype_key != prototype_desc:
|
||||
caller.msg("(Replacing `prototype_desc` in prototype with given desc.)")
|
||||
prototype['prototype_desc'] = prototype_desc
|
||||
prototype["prototype_desc"] = prototype_desc
|
||||
if prototype_tags is not None and prototype.get("prototype_tags") != prototype_tags:
|
||||
caller.msg("(Replacing `prototype_tags` in prototype with given tag(s))" )
|
||||
prototype['prototype_tags'] = prototype_tags
|
||||
caller.msg("(Replacing `prototype_tags` in prototype with given tag(s))")
|
||||
prototype["prototype_tags"] = prototype_tags
|
||||
|
||||
string = ""
|
||||
# check for existing prototype (exact match)
|
||||
@ -3635,11 +3638,17 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
if old_prototype:
|
||||
if not diffstr:
|
||||
string = f"|yAlready existing Prototype:|n\n{new_prototype_detail}\n"
|
||||
question = "\nThere seems to be no changes. Do you still want to (re)save? [Y]/N"
|
||||
question = (
|
||||
"\nThere seems to be no changes. Do you still want to (re)save? [Y]/N"
|
||||
)
|
||||
else:
|
||||
string = (f"|yExisting prototype \"{prototype_key}\" found. Change:|n\n{diffstr}\n"
|
||||
f"|yNew changed prototype:|n\n{new_prototype_detail}")
|
||||
question = "\n|yDo you want to apply the change to the existing prototype?|n [Y]/N"
|
||||
string = (
|
||||
f'|yExisting prototype "{prototype_key}" found. Change:|n\n{diffstr}\n'
|
||||
f"|yNew changed prototype:|n\n{new_prototype_detail}"
|
||||
)
|
||||
question = (
|
||||
"\n|yDo you want to apply the change to the existing prototype?|n [Y]/N"
|
||||
)
|
||||
else:
|
||||
string = f"|yCreating new prototype:|n\n{new_prototype_detail}"
|
||||
question = "\nDo you want to continue saving? [Y]/N"
|
||||
@ -3692,8 +3701,11 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
except protlib.PermissionError as err:
|
||||
retmsg = f"|rError deleting:|R {err}|n"
|
||||
else:
|
||||
retmsg = ("Deletion successful" if success else
|
||||
"Deletion failed (does the prototype exist?)")
|
||||
retmsg = (
|
||||
"Deletion successful"
|
||||
if success
|
||||
else "Deletion failed (does the prototype exist?)"
|
||||
)
|
||||
caller.msg(retmsg)
|
||||
return
|
||||
|
||||
@ -3726,7 +3738,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||
try:
|
||||
for obj in spawner.spawn(prototype):
|
||||
self.caller.msg("Spawned %s." % obj.get_display_name(self.caller))
|
||||
if not prototype.get('location') and not noloc:
|
||||
if not prototype.get("location") and not noloc:
|
||||
# we don't hardcode the location in the prototype (unless the user
|
||||
# did so manually) - that would lead to it having to be 'removed' every
|
||||
# time we try to update objects with this prototype in the future.
|
||||
|
||||
@ -1366,7 +1366,9 @@ class TestBuilding(CommandTest):
|
||||
|
||||
# spawn/examine with invalid prototype
|
||||
# shows error
|
||||
self.call(building.CmdSpawn(), "/examine NO_EXISTS", "No prototype named 'NO_EXISTS' was found.")
|
||||
self.call(
|
||||
building.CmdSpawn(), "/examine NO_EXISTS", "No prototype named 'NO_EXISTS' was found."
|
||||
)
|
||||
|
||||
|
||||
class TestComms(CommandTest):
|
||||
|
||||
@ -2179,8 +2179,11 @@ def _format_diff_text_and_options(diff, minimal=True, **kwargs):
|
||||
vsep = "" if len(vold) < 78 else "\n"
|
||||
|
||||
if instruction == "ADD":
|
||||
texts.append(" |c[{optnum}] |yADD|n: {new}".format(
|
||||
optnum=optnum, new=_visualize(new, rootname)))
|
||||
texts.append(
|
||||
" |c[{optnum}] |yADD|n: {new}".format(
|
||||
optnum=optnum, new=_visualize(new, rootname)
|
||||
)
|
||||
)
|
||||
elif instruction == "REMOVE" and not new:
|
||||
if rootname == "tags" and old[1] == protlib.PROTOTYPE_TAG_CATEGORY:
|
||||
# special exception for the prototype-tag mechanism
|
||||
@ -2188,8 +2191,11 @@ def _format_diff_text_and_options(diff, minimal=True, **kwargs):
|
||||
# not be listed as REMOVE.
|
||||
return texts, options, optnum
|
||||
|
||||
texts.append(" |c[{optnum}] |rREMOVE|n: {old}".format(
|
||||
optnum=optnum, old=_visualize(old, rootname)))
|
||||
texts.append(
|
||||
" |c[{optnum}] |rREMOVE|n: {old}".format(
|
||||
optnum=optnum, old=_visualize(old, rootname)
|
||||
)
|
||||
)
|
||||
else:
|
||||
vinst = "|y{}|n".format(instruction)
|
||||
texts.append(
|
||||
@ -2294,8 +2300,9 @@ def node_apply_diff(caller, **kwargs):
|
||||
if not custom_location:
|
||||
diff.pop("location", None)
|
||||
|
||||
txt, options = _format_diff_text_and_options(diff, objects=update_objects,
|
||||
base_obj=base_obj, prototype=prototype)
|
||||
txt, options = _format_diff_text_and_options(
|
||||
diff, objects=update_objects, base_obj=base_obj, prototype=prototype
|
||||
)
|
||||
|
||||
if options:
|
||||
text = [
|
||||
|
||||
@ -124,13 +124,13 @@ def homogenize_prototype(prototype, custom_keys=None):
|
||||
|
||||
# add required missing parts that had defaults before
|
||||
|
||||
homogenized["prototype_key"] = homogenized.get("prototype_key",
|
||||
homogenized["prototype_key"] = homogenized.get(
|
||||
"prototype_key",
|
||||
# assign a random hash as key
|
||||
"prototype-{}".format(
|
||||
hashlib.md5(bytes(str(time.time()), "utf-8")).hexdigest()[:7]))
|
||||
"prototype-{}".format(hashlib.md5(bytes(str(time.time()), "utf-8")).hexdigest()[:7]),
|
||||
)
|
||||
homogenized["prototype_tags"] = homogenized.get("prototype_tags", [])
|
||||
homogenized["prototype_locks"] = homogenized.get(
|
||||
"prototype_lock", _PROTOTYPE_FALLBACK_LOCK)
|
||||
homogenized["prototype_locks"] = homogenized.get("prototype_lock", _PROTOTYPE_FALLBACK_LOCK)
|
||||
homogenized["prototype_desc"] = homogenized.get("prototype_desc", "")
|
||||
if "typeclass" not in prototype and "prototype_parent" not in prototype:
|
||||
homogenized["typeclass"] = settings.BASE_OBJECT_TYPECLASS
|
||||
@ -752,7 +752,7 @@ def prototype_to_str(prototype):
|
||||
)
|
||||
attrs = "|cattrs:|n\n {attrs}".format(attrs="\n ".join(out))
|
||||
if "tags" in prototype:
|
||||
tags = prototype['tags']
|
||||
tags = prototype["tags"]
|
||||
out = []
|
||||
for (tagkey, category, data) in tags:
|
||||
out.append(
|
||||
|
||||
@ -171,13 +171,14 @@ class Unset:
|
||||
Helper class representing a non-set diff element.
|
||||
|
||||
"""
|
||||
|
||||
def __bool__(self):
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
return "<Unset>"
|
||||
|
||||
|
||||
|
||||
# Helper
|
||||
|
||||
|
||||
@ -405,7 +406,9 @@ def prototype_diff(prototype1, prototype2, maxdepth=2, homogenize=False, implici
|
||||
new_map = {part[0] if is_iter(part) else part: part for part in new}
|
||||
all_keys = set(list(old_map.keys()) + list(new_map.keys()))
|
||||
return {
|
||||
key: _recursive_diff(old_map.get(key, _unset), new_map.get(key, _unset), depth=depth + 1)
|
||||
key: _recursive_diff(
|
||||
old_map.get(key, _unset), new_map.get(key, _unset), depth=depth + 1
|
||||
)
|
||||
for key in all_keys
|
||||
}
|
||||
elif old != new:
|
||||
@ -520,8 +523,9 @@ def prototype_diff_from_object(prototype, obj, implicit_keep=True):
|
||||
|
||||
"""
|
||||
obj_prototype = prototype_from_object(obj)
|
||||
diff = prototype_diff(obj_prototype, protlib.homogenize_prototype(prototype),
|
||||
implicit_keep=implicit_keep)
|
||||
diff = prototype_diff(
|
||||
obj_prototype, protlib.homogenize_prototype(prototype), implicit_keep=implicit_keep
|
||||
)
|
||||
return diff, obj_prototype
|
||||
|
||||
|
||||
|
||||
@ -212,7 +212,7 @@ class TestUtils(EvenniaTest):
|
||||
"puppet:pperm(Developer);tell:perm(Admin);view:all()",
|
||||
"KEEP",
|
||||
),
|
||||
"prototype_tags": (None, None, 'KEEP'),
|
||||
"prototype_tags": (None, None, "KEEP"),
|
||||
"attrs": {
|
||||
"oldtest": (
|
||||
("oldtest", "to_keep", None, ""),
|
||||
@ -269,7 +269,7 @@ class TestUtils(EvenniaTest):
|
||||
new_prot = spawner.prototype_from_object(self.obj1)
|
||||
self.assertEqual(
|
||||
{
|
||||
"aliases": ['foo'],
|
||||
"aliases": ["foo"],
|
||||
"attrs": [
|
||||
("desc", "changed desc", None, ""),
|
||||
("fooattr", "fooattrval", None, ""),
|
||||
@ -294,9 +294,7 @@ class TestUtils(EvenniaTest):
|
||||
"view:all()",
|
||||
]
|
||||
),
|
||||
'tags': [
|
||||
('footag', 'foocategory', None),
|
||||
(Something, 'from_prototype', None)],
|
||||
"tags": [("footag", "foocategory", None), (Something, "from_prototype", None)],
|
||||
"permissions": ["builder"],
|
||||
"prototype_desc": "Built from Obj",
|
||||
"prototype_key": Something,
|
||||
@ -927,7 +925,7 @@ class TestMenuModule(EvenniaTest):
|
||||
"\n- |wprototype_locks:|n"
|
||||
"\n- |wprototype_tags:|n"
|
||||
"\n- |wtags:|n |c[3] |yADD|n: foo |W(category:|n None|W)|n"
|
||||
"\n- |wtypeclass:|n"
|
||||
"\n- |wtypeclass:|n",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
|
||||
@ -272,7 +272,7 @@ class EvMore(object):
|
||||
Paginate by slice. This is done with an eye on memory efficiency (usually for
|
||||
querysets); to avoid fetching all objects at the same time.
|
||||
"""
|
||||
return self._data[pageno * self.height: pageno * self.height + self.height]
|
||||
return self._data[pageno * self.height : pageno * self.height + self.height]
|
||||
|
||||
# inits for different input types
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user