Fix single-attribute examine on not-found
This commit is contained in:
parent
7c9705d90a
commit
23767f4205
1 changed files with 10 additions and 3 deletions
|
|
@ -2375,6 +2375,8 @@ class CmdExamine(ObjManipCommand):
|
||||||
value (any): Attribute value.
|
value (any): Attribute value.
|
||||||
Returns:
|
Returns:
|
||||||
"""
|
"""
|
||||||
|
if attr is None:
|
||||||
|
return "No such attribute was found."
|
||||||
value = utils.to_str(value)
|
value = utils.to_str(value)
|
||||||
if crop:
|
if crop:
|
||||||
value = utils.crop(value)
|
value = utils.crop(value)
|
||||||
|
|
@ -2390,19 +2392,24 @@ class CmdExamine(ObjManipCommand):
|
||||||
non-persistent data stored on object
|
non-persistent data stored on object
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if attrname:
|
if attrname:
|
||||||
|
if obj.attributes.has(attrname):
|
||||||
db_attr = [(attrname, obj.attributes.get(attrname), None)]
|
db_attr = [(attrname, obj.attributes.get(attrname), None)]
|
||||||
|
else:
|
||||||
|
db_attr = None
|
||||||
try:
|
try:
|
||||||
ndb_attr = [(attrname, object.__getattribute__(obj.ndb, attrname))]
|
ndb_attr = [(attrname, object.__getattribute__(obj.ndb, attrname))]
|
||||||
except Exception:
|
except Exception:
|
||||||
ndb_attr = None
|
ndb_attr = None
|
||||||
|
if not (db_attr or ndb_attr):
|
||||||
|
return {"Attribue(s)": f"\n No Attribute '{attrname}' found on {obj.name}"}
|
||||||
else:
|
else:
|
||||||
db_attr = [(attr.key, attr.value, attr.category) for attr in obj.db_attributes.all()]
|
db_attr = [(attr.key, attr.value, attr.category) for attr in obj.db_attributes.all()]
|
||||||
try:
|
try:
|
||||||
ndb_attr = obj.nattributes.all(return_tuples=True)
|
ndb_attr = obj.nattributes.all(return_tuples=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
ndb_attr = None
|
ndb_attr = (None, None, None)
|
||||||
|
|
||||||
output = {}
|
output = {}
|
||||||
if db_attr and db_attr[0]:
|
if db_attr and db_attr[0]:
|
||||||
output["Persistent attribute(s)"] = "\n " + "\n ".join(
|
output["Persistent attribute(s)"] = "\n " + "\n ".join(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue