MCInfo: more compact row iteration

This commit is contained in:
James Lu 2017-03-08 18:39:40 -08:00
parent 35e82ca785
commit 8bc77c8f63

View File

@ -153,12 +153,11 @@ class MCInfo(callbacks.Plugin):
recipe.append(rowitems) recipe.append(rowitems)
irc.reply("Recipe for %s uses: %s" % (ircutils.bold(item), ircutils.bold(ingredients))) irc.reply("Recipe for %s uses: %s" % (ircutils.bold(item), ircutils.bold(ingredients)))
for row in recipe: for row in filter(any, recipe): # Only output rows that have filled squares.
if any(row): # Only output rows that have filled squares. # For each item, center its name based on the length of the longest item name in the
# For each item, center its name based on the length of the longest item name in the # recipe. This gives the grid a more monospace-y feel.
# recipe. This gives the grid a more monospace-y feel. items = [s.center(maxitemlength, '-') for s in row]
items = [s.center(maxitemlength, '-') for s in row] irc.reply('|%s|' % '|'.join(items))
irc.reply('|%s|' % '|'.join(items))
@wrap(['text']) @wrap(['text'])
def smelt(self, irc, msg, args, item): def smelt(self, irc, msg, args, item):