Changed some defaults of EvTable. Made EvTable handle clist command. Resolves #426.
This commit is contained in:
parent
d99d52fa5a
commit
e45160a12b
2 changed files with 12 additions and 16 deletions
|
|
@ -13,7 +13,7 @@ from src.comms.models import ChannelDB, Msg
|
||||||
from src.players.models import PlayerDB
|
from src.players.models import PlayerDB
|
||||||
from src.players import bots
|
from src.players import bots
|
||||||
from src.comms.channelhandler import CHANNELHANDLER
|
from src.comms.channelhandler import CHANNELHANDLER
|
||||||
from src.utils import create, utils, prettytable
|
from src.utils import create, utils, prettytable, evtable
|
||||||
from src.utils.utils import make_iter
|
from src.utils.utils import make_iter
|
||||||
from src.commands.default.muxcommand import MuxCommand, MuxPlayerCommand
|
from src.commands.default.muxcommand import MuxCommand, MuxPlayerCommand
|
||||||
|
|
||||||
|
|
@ -276,13 +276,12 @@ class CmdChannels(MuxPlayerCommand):
|
||||||
|
|
||||||
if self.cmdstring == "comlist":
|
if self.cmdstring == "comlist":
|
||||||
# just display the subscribed channels with no extra info
|
# just display the subscribed channels with no extra info
|
||||||
comtable = prettytable.PrettyTable(["{wchannel",
|
comtable = evtable.EvTable("{wchannel{n", "{wmy aliases{n", "{wdescription{n", align="l", maxwidth=78)
|
||||||
"{wmy aliases",
|
#comtable = prettytable.PrettyTable(["{wchannel", "{wmy aliases", "{wdescription"])
|
||||||
"{wdescription"])
|
|
||||||
for chan in subs:
|
for chan in subs:
|
||||||
clower = chan.key.lower()
|
clower = chan.key.lower()
|
||||||
nicks = caller.nicks.get(category="channel")
|
nicks = caller.nicks.get(category="channel")
|
||||||
comtable.add_row(["%s%s" % (chan.key, chan.aliases.all() and
|
comtable.add_row(*["%s%s" % (chan.key, chan.aliases.all() and
|
||||||
"(%s)" % ",".join(chan.aliases.all()) or ""),
|
"(%s)" % ",".join(chan.aliases.all()) or ""),
|
||||||
"%s".join(nick for nick in make_iter(nicks)
|
"%s".join(nick for nick in make_iter(nicks)
|
||||||
if nick and nick.lower() == clower),
|
if nick and nick.lower() == clower),
|
||||||
|
|
@ -290,16 +289,13 @@ class CmdChannels(MuxPlayerCommand):
|
||||||
caller.msg("\n{wChannel subscriptions{n (use {w@channels{n to list all, {waddcom{n/{wdelcom{n to sub/unsub):{n\n%s" % comtable)
|
caller.msg("\n{wChannel subscriptions{n (use {w@channels{n to list all, {waddcom{n/{wdelcom{n to sub/unsub):{n\n%s" % comtable)
|
||||||
else:
|
else:
|
||||||
# full listing (of channels caller is able to listen to)
|
# full listing (of channels caller is able to listen to)
|
||||||
comtable = prettytable.PrettyTable(["{wsub",
|
comtable = evtable.EvTable("{wsub{n", "{wchannel{n", "{wmy aliases{n", "{wlocks{n", "{wdescription{n", maxwidth=78)
|
||||||
"{wchannel",
|
#comtable = prettytable.PrettyTable(["{wsub", "{wchannel", "{wmy aliases", "{wlocks", "{wdescription"])
|
||||||
"{wmy aliases",
|
|
||||||
"{wlocks",
|
|
||||||
"{wdescription"])
|
|
||||||
for chan in channels:
|
for chan in channels:
|
||||||
clower = chan.key.lower()
|
clower = chan.key.lower()
|
||||||
nicks = caller.nicks.get(category="channel")
|
nicks = caller.nicks.get(category="channel")
|
||||||
nicks = nicks or []
|
nicks = nicks or []
|
||||||
comtable.add_row([chan in subs and "{gYes{n" or "{rNo{n",
|
comtable.add_row(*[chan in subs and "{gYes{n" or "{rNo{n",
|
||||||
"%s%s" % (chan.key, chan.aliases.all() and
|
"%s%s" % (chan.key, chan.aliases.all() and
|
||||||
"(%s)" % ",".join(chan.aliases.all()) or ""),
|
"(%s)" % ",".join(chan.aliases.all()) or ""),
|
||||||
"%s".join(nick for nick in make_iter(nicks)
|
"%s".join(nick for nick in make_iter(nicks)
|
||||||
|
|
@ -798,7 +794,7 @@ class CmdIRC2Chan(MuxCommand):
|
||||||
ircbots = [bot.typeclass for bot in PlayerDB.objects.filter(db_is_bot=True, username__startswith="ircbot-")]
|
ircbots = [bot.typeclass for bot in PlayerDB.objects.filter(db_is_bot=True, username__startswith="ircbot-")]
|
||||||
if ircbots:
|
if ircbots:
|
||||||
from src.utils.evtable import EvTable
|
from src.utils.evtable import EvTable
|
||||||
table = EvTable("{wdbid{n", "{wbotname{n", "{wev-channel{n", "{wirc-channel{n", border="cells", maxwidth=78)
|
table = EvTable("{wdbid{n", "{wbotname{n", "{wev-channel{n", "{wirc-channel{n", maxwidth=78)
|
||||||
for ircbot in ircbots:
|
for ircbot in ircbots:
|
||||||
ircinfo = "%s (%s:%s)" % (ircbot.db.irc_channel, ircbot.db.irc_network, ircbot.db.irc_port)
|
ircinfo = "%s (%s:%s)" % (ircbot.db.irc_channel, ircbot.db.irc_network, ircbot.db.irc_port)
|
||||||
table.add_row(ircbot.id, ircbot.db.irc_botname, ircbot.db.ev_channel, ircinfo)
|
table.add_row(ircbot.id, ircbot.db.irc_botname, ircbot.db.ev_channel, ircinfo)
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ class Cell(object):
|
||||||
hfill_char - character used for horizontal fill (default " ")
|
hfill_char - character used for horizontal fill (default " ")
|
||||||
vfill_char - character used for vertical fill (default " ")
|
vfill_char - character used for vertical fill (default " ")
|
||||||
|
|
||||||
align - "l", "r" or "c", default is centered
|
align - "l", "r" or "c", default is left-aligned
|
||||||
valign - "t", "b" or "c", default is centered
|
valign - "t", "b" or "c", default is centered
|
||||||
|
|
||||||
border_width -general border width. This is overruled
|
border_width -general border width. This is overruled
|
||||||
|
|
@ -359,7 +359,7 @@ class Cell(object):
|
||||||
self.corner_bottom_right = kwargs.get("corner_bottom_right", corner)
|
self.corner_bottom_right = kwargs.get("corner_bottom_right", corner)
|
||||||
|
|
||||||
# alignments
|
# alignments
|
||||||
self.align = kwargs.get("align", "c")
|
self.align = kwargs.get("align", "l")
|
||||||
self.valign = kwargs.get("valign", "c")
|
self.valign = kwargs.get("valign", "c")
|
||||||
|
|
||||||
#self.data = self._split_lines(unicode(data))
|
#self.data = self._split_lines(unicode(data))
|
||||||
|
|
@ -688,7 +688,7 @@ class EvTable(object):
|
||||||
Width is still given precedence. If
|
Width is still given precedence. If
|
||||||
height is given, table cells will crop
|
height is given, table cells will crop
|
||||||
text rather than expand vertically.
|
text rather than expand vertically.
|
||||||
evenwidth - (default True). Used with the width keyword.
|
evenwidth - (default False). Used with the width keyword.
|
||||||
Adjusts collumns to have as even width as
|
Adjusts collumns to have as even width as
|
||||||
possible. This often looks best also for
|
possible. This often looks best also for
|
||||||
mixed-length tables.
|
mixed-length tables.
|
||||||
|
|
@ -747,7 +747,7 @@ class EvTable(object):
|
||||||
|
|
||||||
self.width = kwargs.pop("width", None)
|
self.width = kwargs.pop("width", None)
|
||||||
self.height = kwargs.pop("height", None)
|
self.height = kwargs.pop("height", None)
|
||||||
self.evenwidth = kwargs.pop("evenwidth", True)
|
self.evenwidth = kwargs.pop("evenwidth", False)
|
||||||
self.maxwidth = kwargs.pop("maxwidth", None)
|
self.maxwidth = kwargs.pop("maxwidth", None)
|
||||||
if self.maxwidth and self.width and self.maxwidth < self.width:
|
if self.maxwidth and self.width and self.maxwidth < self.width:
|
||||||
raise Exception("table maxwidth < table width!")
|
raise Exception("table maxwidth < table width!")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue