Updated docstrings as an example

This commit is contained in:
Griatch 2015-03-04 21:42:23 +01:00
parent a70969f221
commit 21e4a6bca7
2 changed files with 44 additions and 40 deletions

View file

@ -322,64 +322,65 @@ class DefaultObject(ObjectDB):
nofound_string=None, nofound_string=None,
multimatch_string=None): multimatch_string=None):
""" """
Returns the typeclass of an Object matching a search string/condition Returns the typeclass of an `Object` matching a search
string/condition
Perform a standard object search in the database, handling Perform a standard object search in the database, handling
multiple results and lack thereof gracefully. By default, only multiple results and lack thereof gracefully. By default, only
objects in self's current location or inventory is searched. objects in the current `location` of `self` or its inventory are searched for.
Note: to find Players, use eg. evennia.player_search.
Args: Args:
searchdata (str or obj): Primary search criterion. Will be matched searchdata (str or obj): Primary search criterion. Will be matched
against object.key (with object.aliases second) unless against `object.key` (with `object.aliases` second) unless
the keyword attribute_name specifies otherwise. the keyword attribute_name specifies otherwise.
Special strings: **Special strings:**
#<num> - search by unique dbref. This is always - `#<num>`: search by unique dbref. This is always
a global search. a global search.
me,self - self-reference to this object - `me,self`: self-reference to this object
<num>-<string> - can be used to differentiate - `<num>-<string>` - can be used to differentiate
between multiple same-named matches between multiple same-named matches
global_search (bool): Search all objects globally. This is overruled global_search (bool): Search all objects globally. This is overruled
by "location" keyword. by `location` keyword.
use_nicks (bool): Use nickname-replace (nicktype "object") on the use_nicks (bool): Use nickname-replace (nicktype "object") on `searchdata`.
search string
typeclass (str or Typeclass, or list of either): Limit search only typeclass (str or Typeclass, or list of either): Limit search only
to Objects with this typeclass. May be a list of typeclasses to `Objects` with this typeclass. May be a list of typeclasses
for a broader search. for a broader search.
location (Object): Specify a location to search, if different from the location (Object): Specify a location to search, if different from the
self's given location plus its contents. This can also self's given `location` plus its contents. This can also
be a list of locations. be a list of locations.
attribute_name (str): Define which property to search. If set, no attribute_name (str): Define which property to search. If set, no
key+alias search will be performed. This can be used to key+alias search will be performed. This can be used
search database fields (db_ will be automatically to search database fields (db_ will be automatically
appended), and if that fails, it will try to return appended), and if that fails, it will try to return
objects having Attributes with this name and value objects having Attributes with this name and value
equal to searchdata. A special use is to search for equal to searchdata. A special use is to search for
"key" here if you want to do a key-search without "key" here if you want to do a key-search without
including aliases. including aliases.
quiet (bool): don't display default error messages - this tells the quiet (bool): don't display default error messages - this tells the
search method that the user wants to handle all errors search method that the user wants to handle all errors
themselves. It also changes the return value type, see themselves. It also changes the return value type, see
below. below.
exact (bool): if unset (default) - prefers to match to beginning of exact (bool): if unset (default) - prefers to match to beginning of
string rather than not matching at all. If set, requires string rather than not matching at all. If set, requires
exact mathing of entire string. exact mathing of entire string.
candidates (list of objects): this is an optional custom list of objects candidates (list of objects): this is an optional custom list of objects
to search (filter) between. It is ignored if global_search to search (filter) between. It is ignored if `global_search`
is given. If not set, this list will automatically be defined is given. If not set, this list will automatically be defined
to include the location, the contents of location and the to include the location, the contents of location and the
caller's contents (inventory). caller's contents (inventory).
nofound_string (str): optional custom string for not-found error message nofound_string (str): optional custom string for not-found error message.
multimatch_string (str): optional custom string for multimatch error header multimatch_string (str): optional custom string for multimatch error header.
Returns: Returns:
match (Object, None or list): will return an Object/None if quiet=False, match (Object, None or list): will return an Object/None if `quiet=False`,
otherwise it will return a list of 0, 1 or more matches. otherwise it will return a list of 0, 1 or more matches.
Notes: Notes:
If quiet=False, error messages will be handled by settings.SEARCH_AT_RESULT To find Players, use eg. `evennia.player_search`. If
and echoed automatically (on error, return will be None). If quiet=True, the `quiet=False`, error messages will be handled by
error messaging is assumed to be handled by the caller. `settings.SEARCH_AT_RESULT` and echoed automatically (on
error, return will be `None`). If `quiet=True`, the error
messaging is assumed to be handled by the caller.
""" """
is_string = isinstance(searchdata, basestring) is_string = isinstance(searchdata, basestring)

View file

@ -0,0 +1,3 @@
"""
The idmapper holds the main database caching mechanism.
"""