Remove duplicate dbref implementation in comms-manager. Resolves #2054
This commit is contained in:
parent
49b34f390d
commit
23cbacfa5e
1 changed files with 1 additions and 26 deletions
|
|
@ -8,6 +8,7 @@ Comm system components.
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from evennia.typeclasses.managers import TypedObjectManager, TypeclassManager
|
from evennia.typeclasses.managers import TypedObjectManager, TypeclassManager
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
|
from evennia.utils.utils import dbref
|
||||||
|
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
_AccountDB = None
|
_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):
|
def identify_object(inp):
|
||||||
"""
|
"""
|
||||||
Helper function. Identifies if an object is an account or an object;
|
Helper function. Identifies if an object is an account or an object;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue