@@ -180,9 +180,9 @@ def _moin_row_with_attrs(celltag, cell_values, colwidths, colaligns,
180180 "decimal" : '<style="text-align: right;">' }
181181 values_with_attrs = ["{0}{1} {2} " .format (celltag ,
182182 alignment .get (a , '' ),
183- header + c + header )
183+ header + c + header )
184184 for c , a in zip (cell_values , colaligns )]
185- return "" .join (values_with_attrs )+ "||"
185+ return "" .join (values_with_attrs ) + "||"
186186
187187
188188def _latex_line_begin_tabular (colwidths , colaligns , booktabs = False ):
@@ -684,7 +684,8 @@ def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
684684
685685
686686def _align_header (header , alignment , width , visible_width ):
687- "Pad string header to width chars given known visible_width of the header."
687+ """Pad string header to width chars given known visible_width of the
688+ header."""
688689 width += len (header ) - visible_width
689690 if alignment == "left" :
690691 return _padright (width , header )
@@ -704,20 +705,22 @@ def _prepend_row_index(rows, index):
704705 print ('index=' , index )
705706 print ('rows=' , rows )
706707 raise ValueError ('index must be as long as the number of data rows' )
707- rows = [[v ]+ list (row ) for v , row in zip (index , rows )]
708+ rows = [[v ] + list (row ) for v , row in zip (index , rows )]
708709 return rows
709710
710711
711712def _bool (val ):
712- "A wrapper around standard bool() which doesn't throw on NumPy arrays"
713+ """A wrapper around standard bool() which doesn't throw on NumPy
714+ arrays."""
713715 try :
714716 return bool (val )
715717 except ValueError : # val is likely to be a numpy array with many elements
716718 return False
717719
718720
719721def _normalize_tabular_data (tabular_data , headers , showindex = "default" ):
720- """Transform a supported data type to a list of lists, and a list of headers.
722+ """Transform a supported data type to a list of lists, and a list of
723+ headers.
721724
722725 Supported tabular data types:
723726
@@ -878,7 +881,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
878881 nhs = len (headers )
879882 ncols = len (rows [0 ])
880883 if nhs < ncols :
881- headers = ["" ]* (ncols - nhs ) + headers
884+ headers = ["" ] * (ncols - nhs ) + headers
882885
883886 return rows , headers
884887
@@ -1169,11 +1172,12 @@ def tabulate(tabular_data, headers=(), tablefmt="simple",
11691172 indices is used to disable number parsing only on those columns
11701173 e.g. `disable_numparse=[0, 2]` would disable number parsing only on the
11711174 first and third columns.
1175+
11721176 """
11731177 if tabular_data is None :
11741178 tabular_data = []
11751179 list_of_lists , headers = _normalize_tabular_data (
1176- tabular_data , headers , showindex = showindex )
1180+ tabular_data , headers , showindex = showindex )
11771181
11781182 # empty values in the first column of RST tables should be escaped
11791183 # (issue #82). "" should be escaped as "\\ " or ".."
@@ -1207,14 +1211,14 @@ def tabulate(tabular_data, headers=(), tablefmt="simple",
12071211 else : # if floatfmt is list, tuple etc we have one per column
12081212 float_formats = list (floatfmt )
12091213 if len (float_formats ) < len (cols ):
1210- float_formats .extend ((len (cols )- len (float_formats )) *
1214+ float_formats .extend ((len (cols ) - len (float_formats )) *
12111215 [_DEFAULT_FLOATFMT ])
12121216 if isinstance (missingval , basestring ):
12131217 missing_vals = len (cols ) * [missingval ]
12141218 else :
12151219 missing_vals = list (missingval )
12161220 if len (missing_vals ) < len (cols ):
1217- missing_vals .extend ((len (cols )- len (missing_vals )) *
1221+ missing_vals .extend ((len (cols ) - len (missing_vals )) *
12181222 [_DEFAULT_MISSINGVAL ])
12191223 cols = [[_format (v , ct , fl_fmt , miss_v , has_invisible ) for v in c ]
12201224 for c , ct , fl_fmt , miss_v in zip (cols , coltypes , float_formats ,
@@ -1223,7 +1227,7 @@ def tabulate(tabular_data, headers=(), tablefmt="simple",
12231227 # align columns
12241228 aligns = [numalign if ct in [int , float ] else stralign for ct in coltypes ]
12251229 minwidths = [width_fn (h ) + MIN_PADDING
1226- for h in headers ] if headers else [0 ]* len (cols )
1230+ for h in headers ] if headers else [0 ] * len (cols )
12271231 cols = [_align_column (c , a , minw , has_invisible )
12281232 for c , a , minw in zip (cols , aligns , minwidths )]
12291233
@@ -1247,12 +1251,13 @@ def tabulate(tabular_data, headers=(), tablefmt="simple",
12471251
12481252
12491253def _expand_numparse (disable_numparse , column_count ):
1250- """
1251- Return a list of bools of length `column_count` which indicates whether
1254+ """Return a list of bools of length `column_count` which indicates whether
12521255 number parsing should be used on each column.
1253- If `disable_numparse` is a list of indices, each of those indices are
1254- False, and everything else is True.
1255- If `disable_numparse` is a bool, then the returned list is all the same.
1256+
1257+ If `disable_numparse` is a list of indices, each of those indices
1258+ are False, and everything else is True. If `disable_numparse` is a
1259+ bool, then the returned list is all the same.
1260+
12561261 """
12571262 if isinstance (disable_numparse , Iterable ):
12581263 numparses = [True ] * column_count
@@ -1346,8 +1351,7 @@ def _format_table(fmt, headers, rows, colwidths, colaligns):
13461351
13471352
13481353def _main ():
1349- """\
1350- Usage: tabulate [options] [FILE ...]
1354+ """\ Usage: tabulate [options] [FILE ...]
13511355
13521356 Pretty-print tabular data.
13531357 See also https://bitbucket.org/astanin/python-tabulate
@@ -1367,6 +1371,7 @@ def _main():
13671371 rst, mediawiki, html, latex, latex_raw,
13681372 latex_booktabs, tsv
13691373 (default: simple)
1374+
13701375 """
13711376 import getopt
13721377 import sys
0 commit comments