Make PEP8 cleanup of line spaces and character distances as well as indents

This commit is contained in:
Griatch 2017-08-19 23:16:36 +02:00
parent 7ff783fea1
commit b278337172
189 changed files with 2039 additions and 1583 deletions

View file

@ -59,7 +59,7 @@ class ChannelAdmin(admin.ModelAdmin):
list_select_related = True
fieldsets = (
(None, {'fields': (('db_key',), 'db_lock_storage', 'db_subscriptions')}),
)
)
def subscriptions(self, obj):
"""

View file

@ -34,6 +34,7 @@ from django.utils.translation import ugettext as _
_CHANNEL_COMMAND_CLASS = None
_CHANNELDB = None
class ChannelCommand(command.Command):
"""
{channelkey} channel
@ -130,8 +131,9 @@ class ChannelCommand(command.Command):
if self.history_start is not None:
# Try to view history
log_file = channel.attributes.get("log_file", default="channel_%s.log" % channel.key)
send_msg = lambda lines: self.msg("".join(line.split("[-]", 1)[1]
if "[-]" in line else line for line in lines))
def send_msg(lines): return self.msg("".join(line.split("[-]", 1)[1]
if "[-]" in line else line for line in lines))
tail_log_file(log_file, self.history_start, 20, callback=send_msg)
else:
caller = caller if not hasattr(caller, 'account') else caller.account
@ -164,6 +166,7 @@ class ChannelHandler(object):
evennia.create_channel())
"""
def __init__(self):
"""
Initializes the channel handler's internal state.
@ -208,12 +211,12 @@ class ChannelHandler(object):
# map the channel to a searchable command
cmd = _CHANNEL_COMMAND_CLASS(
key=channel.key.strip().lower(),
aliases=channel.aliases.all(),
locks="cmd:all();%s" % channel.locks,
help_category="Channel names",
obj=channel,
is_channel=True)
key=channel.key.strip().lower(),
aliases=channel.aliases.all(),
locks="cmd:all();%s" % channel.locks,
help_category="Channel names",
obj=channel,
is_channel=True)
# format the help entry
key = channel.key
cmd.__doc__ = cmd.__doc__.format(channelkey=key,
@ -221,7 +224,7 @@ class ChannelHandler(object):
channeldesc=channel.attributes.get("desc", default="").strip())
self.cached_channel_cmds[channel] = cmd
self.cached_cmdsets = {}
add_channel = add # legacy alias
add_channel = add # legacy alias
def remove(self, channel):
"""
@ -269,8 +272,8 @@ class ChannelHandler(object):
# create a new cmdset holding all viable channels
chan_cmdset = None
chan_cmds = [channelcmd for channel, channelcmd in self.cached_channel_cmds.iteritems()
if channel.subscriptions.has(source_object) and
channelcmd.access(source_object, 'send')]
if channel.subscriptions.has(source_object) and
channelcmd.access(source_object, 'send')]
if chan_cmds:
chan_cmdset = cmdset.CmdSet()
chan_cmdset.key = 'ChannelCmdSet'
@ -281,5 +284,6 @@ class ChannelHandler(object):
self.cached_cmdsets[source_object] = chan_cmdset
return chan_cmdset
CHANNEL_HANDLER = ChannelHandler()
CHANNELHANDLER = CHANNEL_HANDLER # legacy
CHANNELHANDLER = CHANNEL_HANDLER # legacy

View file

@ -357,7 +357,6 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
# hooks
def channel_prefix(self, msg=None, emit=False, **kwargs):
"""
Hook method. How the channel should prefix itself for users.

View file

@ -74,7 +74,7 @@ def identify_object(inp):
if clsname == "AccountDB":
return inp, "account"
elif clsname == "ObjectDB":
return inp ,"object"
return inp, "object"
elif clsname == "ChannelDB":
return inp, "channel"
if isinstance(inp, basestring):
@ -202,10 +202,10 @@ class MsgManager(TypedObjectManager):
# explicitly exclude channel recipients
if typ == 'account':
return list(self.filter(db_sender_accounts=obj,
db_receivers_channels__isnull=True).exclude(db_hide_from_accounts=obj))
db_receivers_channels__isnull=True).exclude(db_hide_from_accounts=obj))
elif typ == 'object':
return list(self.filter(db_sender_objects=obj,
db_receivers_channels__isnull=True).exclude(db_hide_from_objects=obj))
db_receivers_channels__isnull=True).exclude(db_hide_from_objects=obj))
else:
raise CommError
else:
@ -332,6 +332,7 @@ class ChannelDBManager(TypedObjectManager):
subscribed to the Channel.
"""
def get_all_channels(self):
"""
Get all channels.

View file

@ -3,12 +3,14 @@ from __future__ import unicode_literals
from django.db import models, migrations
def convert_defaults(apps, schema_editor):
ChannelDB = apps.get_model("comms", "ChannelDB")
for channel in ChannelDB.objects.filter(db_typeclass_path="src.comms.comms.Channel"):
channel.db_typeclass_path = "typeclasses.channels.Channel"
channel.save()
class Migration(migrations.Migration):
dependencies = [
@ -16,5 +18,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(convert_defaults),
migrations.RunPython(convert_defaults),
]

View file

@ -3,6 +3,7 @@ from __future__ import unicode_literals
from django.db import migrations
def convert_channelnames(apps, schema_editor):
ChannelDB = apps.get_model("comms", "ChannelDB")
for chan in ChannelDB.objects.filter(db_key="MUDinfo"):
@ -13,6 +14,7 @@ def convert_channelnames(apps, schema_editor):
chan.db_key = "MudInfo"
chan.save()
class Migration(migrations.Migration):
dependencies = [
@ -20,5 +22,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(convert_channelnames),
migrations.RunPython(convert_channelnames),
]

View file

@ -26,41 +26,41 @@ class Migration(migrations.Migration):
db_cursor = connection.cursor()
operations = [
migrations.AddField(
model_name='channeldb',
name='db_account_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='account_subscription_set', to='accounts.AccountDB', verbose_name=b'account subscriptions'),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name=b'object subscriptions'),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text=b'script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name=b'sender(script)'),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name=b'object subscriptions'),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text=b'script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name=b'sender(script)'),
),
migrations.AddField(
model_name='channeldb',
name='db_account_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='account_subscription_set', to='accounts.AccountDB', verbose_name=b'account subscriptions'),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name=b'object subscriptions'),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text=b'script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name=b'sender(script)'),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name=b'object subscriptions'),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text=b'script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name=b'sender(script)'),
),
]
if _table_exists(db_cursor, 'comms_msg_db_hide_from_players'):

View file

@ -81,27 +81,27 @@ class Msg(SharedMemoryModel):
# an IRC channel; normally there is only one, but if co-modification of
# a message is allowed, there may be more than one "author"
db_sender_accounts = models.ManyToManyField("accounts.AccountDB", related_name='sender_account_set',
blank=True, verbose_name='sender(account)', db_index=True)
blank=True, verbose_name='sender(account)', db_index=True)
db_sender_objects = models.ManyToManyField("objects.ObjectDB", related_name='sender_object_set',
blank=True, verbose_name='sender(object)', db_index=True)
db_sender_scripts = models.ManyToManyField("scripts.ScriptDB", related_name='sender_script_set',
blank=True, verbose_name='sender(script)', db_index=True)
db_sender_external = models.CharField('external sender', max_length=255, null=True, blank=True, db_index=True,
help_text="identifier for external sender, for example a sender over an "
"IRC connection (i.e. someone who doesn't have an exixtence in-game).")
help_text="identifier for external sender, for example a sender over an "
"IRC connection (i.e. someone who doesn't have an exixtence in-game).")
# The destination objects of this message. Stored as a
# comma-separated string of object dbrefs. Can be defined along
# with channels below.
db_receivers_accounts = models.ManyToManyField('accounts.AccountDB', related_name='receiver_account_set',
blank=True, help_text="account receivers")
blank=True, help_text="account receivers")
db_receivers_objects = models.ManyToManyField('objects.ObjectDB', related_name='receiver_object_set',
blank=True, help_text="object receivers")
db_receivers_scripts = models.ManyToManyField('scripts.ScriptDB', related_name='receiver_script_set',
blank=True, help_text="script_receivers")
db_receivers_channels = models.ManyToManyField("ChannelDB", related_name='channel_set',
blank=True, help_text="channel recievers")
blank=True, help_text="channel recievers")
# header could be used for meta-info about the message if your system needs
# it, or as a separate store for the mail subject line maybe.
@ -122,7 +122,7 @@ class Msg(SharedMemoryModel):
db_hide_from_channels = models.ManyToManyField("ChannelDB", related_name='hide_from_channels_set', blank=True)
db_tags = models.ManyToManyField(Tag, blank=True,
help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.')
help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.')
# Database manager
objects = managers.MsgManager()
@ -156,10 +156,10 @@ class Msg(SharedMemoryModel):
#@property
def __senders_get(self):
"Getter. Allows for value = self.sender"
return list(self.db_sender_accounts.all()) + \
list(self.db_sender_objects.all()) + \
list(self.db_sender_scripts.all()) + \
self.extra_senders
return list(self.db_sender_accounts.all()) + \
list(self.db_sender_objects.all()) + \
list(self.db_sender_scripts.all()) + \
self.extra_senders
#@sender.setter
def __senders_set(self, senders):
@ -225,9 +225,9 @@ class Msg(SharedMemoryModel):
Returns four lists of receivers: accounts, objects, scripts and channels.
"""
return list(self.db_receivers_accounts.all()) + \
list(self.db_receivers_objects.all()) + \
list(self.db_receivers_scripts.all()) + \
list(self.db_receivers_channels.all())
list(self.db_receivers_objects.all()) + \
list(self.db_receivers_scripts.all()) + \
list(self.db_receivers_channels.all())
#@receivers.setter
def __receivers_set(self, receivers):
@ -250,7 +250,6 @@ class Msg(SharedMemoryModel):
elif clsname == "ChannelDB":
self.db_receivers_channels.add(receiver)
#@receivers.deleter
def __receivers_del(self):
"Deleter. Clears all receivers"
@ -370,6 +369,7 @@ class Msg(SharedMemoryModel):
#
#------------------------------------------------------------
class TempMsg(object):
"""
This is a non-persistent object for sending temporary messages
@ -377,6 +377,7 @@ class TempMsg(object):
doesn't require sender to be given.
"""
def __init__(self, senders=None, receivers=None, channels=None, message="", header="", type="", lockstring="", hide_from=None):
"""
Creates the temp message.
@ -471,6 +472,7 @@ class SubscriptionHandler(object):
channel and hides away which type of entity is
subscribing (Account or Object)
"""
def __init__(self, obj):
"""
Initialize the handler
@ -620,10 +622,10 @@ class ChannelDB(TypedObject):
"""
db_account_subscriptions = models.ManyToManyField("accounts.AccountDB",
related_name="account_subscription_set", blank=True, verbose_name='account subscriptions', db_index=True)
related_name="account_subscription_set", blank=True, verbose_name='account subscriptions', db_index=True)
db_object_subscriptions = models.ManyToManyField("objects.ObjectDB",
related_name="object_subscription_set", blank=True, verbose_name='object subscriptions', db_index=True)
related_name="object_subscription_set", blank=True, verbose_name='object subscriptions', db_index=True)
# Database manager
objects = managers.ChannelDBManager()