X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=b8c52af74768053d27b4642173022af3b2c6723d;hb=d4f64cabf4ede444b390bb71b90ad4103ce572c0;hp=d22b0313460f4dc42453bcd7772bd59f5dcfe074;hpb=3fcfb8e9faf3cf1dcadedd6fecc5158a86d07065;p=youtube-dl diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index d22b03134..b8c52af74 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1659,3 +1659,11 @@ def determine_protocol(info_dict): return 'f4m' return compat_urllib_parse_urlparse(url).scheme + + +def render_table(header_row, data): + """ Render a list of rows, each as a list of values """ + table = [header_row] + data + max_lens = [max(len(compat_str(v)) for v in col) for col in zip(*table)] + format_str = ' '.join('%-' + compat_str(ml + 1) + 's' for ml in max_lens[:-1]) + '%s' + return '\n'.join(format_str % tuple(row) for row in table)