def test_2_cp_in_cp(self): cp = ColumnPrinter( cols=[Column(width=20), Column(width=40), Column(width=40)]) incp = ColumnPrinter(cols=[Column(width=20), Column(width=20)], row_width=40) incp2 = ColumnPrinter(cols=[Column(width=20), Column(fill=True)], row_width=40) cp.printf('test', incp, incp2) incp.printf('first-1', '1') incp2.printf('first-2', '1') incp.printf('second-1', '2') incp2.printf('second-2', '2') incp.printf('third-1', '3') incp.printf('fourth-1', '4') incp2.printf('third-2', '3') incp2.done() incp.printf('more-1', 'm') incp.printf('more-1', 'm') incp.printf('more-1', 'm') incp.done() cp.printf('done')
def stats(self): 'Print wallpaper statistics.' st = Statistics() cp = ColumnPrinter( cols=[Column( width=30), SepColumn(), Column(fill=True)]) cp.printf('wallpaper count', str(st.wallpaper_count)) cp.printf('usage time', str(st.usage_time)) cp.printf('avg life of a wallpaper', st.avg_wallpaper_life) cp.printf('avg image size', format_size(st.avg_downloaded_image_size)) cp.printf() incp = ColumnPrinter( cols=[Column(width=30), SepColumn(), Column(width=6, align='r')], row_width=38) cp.printf('top domains', incp) for domain, count in st.top_domains: incp.printf(domain, str(count)) incp.done()
def test_cp_in_cp(self): cp = ColumnPrinter(cols=[Column(width=20), Column(width=40)]) incp = ColumnPrinter(cols=[Column(width=20), Column(width=20)], row_width=40) cp.printf('test', incp) incp.printf('first', '1') incp.printf('second', '2') incp.printf('third', '3') cp.printf('done') incp.done() incp.printf('extra') # should not print
def test_progress_in_inner_cp(self): cp = ColumnPrinter(cols=[Column(width=20), Column(width=50)]) incp = ColumnPrinter( cols=[Column(width=20), ProgressColumn(pwidth=10)], row_width=50) cp.printf('start') cp.printf('progress', incp) cb = incp.printf('downloading', '?') for i in range(0, 101): cb.progress_cb(1, i) sleep(0.05) cb.progress_cp(1) incp.done() cp.printf('done')