def refresh_display(self, d):
        "Redraw the screen with the current data."
        logging.debug('UI: refreshing the display')
        self.win.erase()
        height, width = self.win.getmaxyx()
        logging.debug('UI: size is %d x %d' % (width, height))

        n = len(d)
        s = sum(d.values())

        largest_keys = heapq.nlargest(min(n, 2 - height), d, key=d.__getitem__)
        largest = [(d[l], l) for l in largest_keys]

        logging.debug('UI: redraw call')
        self.win.redrawwin()
        self.win.addstr(0, 0, '%d keys, %d counts' % (n, s))
        if largest:
            w = max(6, len(str(max(c for (c, k) in largest))))
            k_len = width - w - 4
            template = u' %%%dd  %%s' % w
            for i, (c, k) in enumerate(largest):
                line = (template % (c, k[:k_len]))[:width]
                try:
                    self.win.addstr(i + 2, 0, line.encode('utf8'))
                except:
                    raise Exception("couldn't draw: '%s'"
                                    % line.encode('utf8'))

        logging.debug('UI: refresh')
        self.win.refresh()
dataset/ETHPy150Open larsyencken/anytop/anytop/top.py/AnyTopUI.refresh_display/swapped operands of `-`