Cleaning some unnecessary whitespace, overall cleanup of various source codes.

This commit is contained in:
Griatch 2012-03-30 23:47:22 +02:00
parent d4c97d7df8
commit c0322c9eae
27 changed files with 1342 additions and 1318 deletions

View file

@ -23,9 +23,9 @@ class HelpEntryAdmin(admin.ModelAdmin):
list_display_links = ('id', 'db_key')
search_fields = ['^db_key', 'db_entrytext']
ordering = ['db_help_category', 'db_key']
save_as = True
save_on_top = True
list_select_related = True
save_as = True
save_on_top = True
list_select_related = True
form = HelpEntryForm
fieldsets = (

View file

@ -6,10 +6,10 @@ from src.utils import logger, utils
class HelpEntryManager(models.Manager):
"""
This HelpEntryManager implements methods for searching
This HelpEntryManager implements methods for searching
and manipulating HelpEntries directly from the database.
These methods will all return database objects
These methods will all return database objects
(or QuerySets) directly.
Evennia-specific:
@ -24,33 +24,33 @@ class HelpEntryManager(models.Manager):
def find_topicmatch(self, topicstr, exact=False):
"""
Searches for matching topics based on player's input.
"""
"""
if utils.dbref(topicstr):
return self.filter(id=utils.dbref(topicstr))
topics = self.filter(db_key__iexact=topicstr)
if not topics and not exact:
topics = self.filter(db_key__istartswith=topicstr)
if not topics and not exact:
topics = self.filter(db_key__istartswith=topicstr)
if not topics:
topics = self.filter(db_key__icontains=topicstr)
topics = self.filter(db_key__icontains=topicstr)
return topics
def find_apropos(self, topicstr):
"""
Do a very loose search, returning all help entries containing
the search criterion in their titles.
the search criterion in their titles.
"""
return self.filter(db_key__icontains=topicstr)
def find_topicsuggestions(self, topicstr):
"""
Do a fuzzy match, preferably within the category of the
current topic.
"""
topics = self.find_apropos(topicstr)
"""
topics = self.find_apropos(topicstr)
# we need to clean away the given help entry.
return [topic for topic in topics
if topic.key.lower() != topicstr.lower()]
def find_topics_with_category(self, help_category):
"""
Search topics having a particular category
@ -76,7 +76,7 @@ class HelpEntryManager(models.Manager):
Shifts all help entries in database to default_category.
This action cannot be reverted. It is used primarily by
the engine when importing a default help database, making
sure this ends up in one easily separated category.
sure this ends up in one easily separated category.
"""
topics = self.all()
for topic in topics:
@ -92,7 +92,7 @@ class HelpEntryManager(models.Manager):
ostring - the help topic to look for
category - limit the search to a particular help topic
"""
ostring = ostring.strip().lower()
ostring = ostring.strip().lower()
help_entries = self.filter(db_topicstr=ostring)
if help_category:
help_entries.filter(db_help_category=help_category)

View file

@ -41,20 +41,20 @@ class HelpEntry(SharedMemoryModel):
# These database fields are all set using their corresponding properties,
# named same as the field, but withtout the db_* prefix.
# title of the help
# title of the help
db_key = models.CharField('help key', max_length=255, unique=True, help_text='key to search for')
# help category
db_help_category = models.CharField("help category", max_length=255, default="General",
# help category
db_help_category = models.CharField("help category", max_length=255, default="General",
help_text='organizes help entries in lists')
# the actual help entry text, in any formatting.
db_entrytext = models.TextField('help entry', blank=True, help_text='the main body of help text')
# the actual help entry text, in any formatting.
db_entrytext = models.TextField('help entry', blank=True, help_text='the main body of help text')
# a string of permissionstrings, separated by commas. Not used by help entries.
db_permissions = models.CharField('permissions', max_length=255, blank=True)
db_permissions = models.CharField('permissions', max_length=255, blank=True)
# lock string storage
db_lock_storage = models.CharField('locks', max_length=512, blank=True, help_text='normally view:all().')
# (deprecated, only here to allow MUX helpfile load (don't use otherwise)).
# TODO: remove this when not needed anymore.
db_staff_only = models.BooleanField(default=False)
# TODO: remove this when not needed anymore.
db_staff_only = models.BooleanField(default=False)
# Database manager
objects = HelpEntryManager()
@ -62,7 +62,7 @@ class HelpEntry(SharedMemoryModel):
def __init__(self, *args, **kwargs):
SharedMemoryModel.__init__(self, *args, **kwargs)
self.locks = LockHandler(self)
class Meta:
"Define Django meta options"
verbose_name = "Help Entry"
@ -72,10 +72,10 @@ class HelpEntry(SharedMemoryModel):
# @property decorators that allows to access these fields using
# normal python operations (without having to remember to save()
# etc). So e.g. a property 'attr' has a get/set/del decorator
# defined that allows the user to do self.attr = value,
# value = self.attr and del self.attr respectively (where self
# defined that allows the user to do self.attr = value,
# value = self.attr and del self.attr respectively (where self
# is the object in question).
# key property (wraps db_key)
#@property
def key_get(self):
@ -137,7 +137,7 @@ class HelpEntry(SharedMemoryModel):
if is_iter(value):
value = ",".join([str(val).strip().lower() for val in value])
self.db_permissions = value
self.save()
self.save()
#@permissions.deleter
def permissions_del(self):
"Deleter. Allows for del self.permissions"
@ -146,7 +146,7 @@ class HelpEntry(SharedMemoryModel):
permissions = property(permissions_get, permissions_set, permissions_del)
# lock_storage property (wraps db_lock_storage)
#@property
#@property
def lock_storage_get(self):
"Getter. Allows for value = self.lock_storage"
return self.db_lock_storage
@ -161,13 +161,13 @@ class HelpEntry(SharedMemoryModel):
logger.log_errmsg("Lock_Storage (on %s) cannot be deleted. Use obj.lock.delete() instead." % self)
lock_storage = property(lock_storage_get, lock_storage_set, lock_storage_del)
#
#
# HelpEntry main class methods
#
#
def __str__(self):
return self.key
@ -180,5 +180,5 @@ class HelpEntry(SharedMemoryModel):
accessing_obj - object trying to access this one
access_type - type of access sought
default - what to return if no lock of access_type was found
"""
"""
return self.locks.check(accessing_obj, access_type=access_type, default=default)