Ran black on sources
This commit is contained in:
parent
86805ef306
commit
ca341278e9
8 changed files with 80 additions and 56 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue