Added Python interpreter version directives and reorganized example scripts
[babeltrace.git] / bindings / python / examples / output_format_modules / pprint_table.py
diff --git a/bindings/python/examples/output_format_modules/pprint_table.py b/bindings/python/examples/output_format_modules/pprint_table.py
deleted file mode 100644 (file)
index a7e8255..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# pprint_table.py
-# 
-# This module is used to pretty-print a table
-# Adapted from
-# http://ginstrom.com/scribbles/2007/09/04/pretty-printing-a-table-in-python/
-
-import sys
-
-def get_max_width(table, index):
-       """Get the maximum width of the given column index"""
-
-       return max([len(str(row[index])) for row in table])
-
-
-def pprint_table(table, nbLeft=1, out=sys.stdout):
-       """
-       Prints out a table of data, padded for alignment
-       @param table: The table to print. A list of lists.
-       Each row must have the same number of columns.
-       @param nbLeft: The number of columns aligned left
-       @param out: Output stream (file-like object)
-       """
-
-       col_paddings = []
-
-       for i in range(len(table[0])):
-               col_paddings.append(get_max_width(table, i))
-
-       for row in table:
-               # left cols
-               for i in range(nbLeft):
-                       print >> out, str(row[i]).ljust(col_paddings[i] + 1),
-               # rest of the cols
-               for i in range(nbLeft, len(row)):
-                       col = str(row[i]).rjust(col_paddings[i] + 2)
-                       print >> out, col,
-               print >> out
This page took 0.023224 seconds and 4 git commands to generate.