def format_metric_table_line(metrics, metrics_per_line, fillvalue=""):
# the final result is a string, ready to add in between <TD></TD>
metric_table_line = ""
# we use izip_longest to iterate through 'metrics' by 'n' elements at a
# time (in this case 'mettrics_per_line')
izip_longest_args = [iter(metrics)] * metrics_per_line
for metric_line in izip_longest(*izip_longest_args, fillvalue=fillvalue):
for metric_str in metric_line:
# append the metric to the metric table line
metric_table_line += strip_metric_str(str(metric_str)) + ","
# add a line break to the table line
metric_table_line = metric_table_line.rstrip(",") + "<BR/>"
return(metric_table_line.rstrip("<BR/>"))
metrics_utils.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录