3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-10-31 16:59:23 +01:00

exec: use a longer length limit when called in private

TODO: these should be made into proper config variables per #612
This commit is contained in:
James Lu 2018-05-30 12:46:23 -07:00
parent c8b2a676fd
commit 2860913562

View File

@ -16,7 +16,9 @@ import pylinkirc
import importlib
exec_locals_dict = {}
# FIXME: make these config vars.
PPRINT_MAX_LINES = 20
PPRINT_MAX_LINES_PRIVATE = 200
PPRINT_WIDTH = 200
def _exec(irc, source, args, locals_dict=None):
@ -92,9 +94,12 @@ def _eval(irc, source, args, locals_dict=None, pretty_print=False):
if pretty_print:
lines = pprint.pformat(result, width=PPRINT_WIDTH, compact=True).splitlines()
for line in lines[:PPRINT_MAX_LINES]:
maxlines = PPRINT_MAX_LINES if irc.is_channel(irc.called_in) else PPRINT_MAX_LINES_PRIVATE
for line in lines[:maxlines]:
irc.reply(line)
if len(lines) > PPRINT_MAX_LINES:
if len(lines) > maxlines:
irc.reply('Suppressing %s more line(s) of output.' % (len(lines) - PPRINT_MAX_LINES))
else:
# Purposely disable text wrapping so results are cut instead of potentially flooding;