Remove duplicate dbref implementation in comms-manager. Resolves #2054

This commit is contained in:
Griatch 2020-02-12 23:19:20 +01:00
parent fc2fbe9812
commit 5644eafe4a

View file

@ -8,6 +8,7 @@ Comm system components.
from django.db.models import Q
from evennia.typeclasses.managers import TypedObjectManager, TypeclassManager
from evennia.utils import logger
from evennia.utils.utils import dbref
_GA = object.__getattribute__
_AccountDB = None
@ -31,32 +32,6 @@ class CommError(Exception):
#
def dbref(inp, reqhash=True):
"""
Valid forms of dbref (database reference number) are either a
string '#N' or an integer N.
Args:
inp (int or str): A possible dbref to check syntactically.
reqhash (bool): Require an initial hash `#` to accept.
Returns:
is_dbref (int or None): The dbref integer part if a valid
dbref, otherwise `None`.
"""
if reqhash and not (isinstance(inp, str) and inp.startswith("#")):
return None
if isinstance(inp, str):
inp = inp.lstrip("#")
try:
if int(inp) < 0:
return None
except Exception:
return None
return inp
def identify_object(inp):
"""
Helper function. Identifies if an object is an account or an object;