Changeset 569

Show
Ignore:
Timestamp:
07/12/08 10:43:00 (5 months ago)
Author:
athomas
Message:

print_table(min_widths=...) now works as intended!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cly/trunk/cly/console.py

    r556 r569  
    471471        Table indentation as a string. 
    472472 
    473     ``auto_format=('^B^U', '^6', '^B^2')``: tuple 
    474         A tuple specifying the formatting colours to use for each row. The 
    475         first element is the header colour, subsequent elements are for 
    476         alternating rows. 
     473    ``header_format='^B^U'``: string 
     474        Formatting to use for header. 
     475 
     476    ``row_format=('^6', '^B^6')``: tuple 
     477        A tuple specifying cycling formatting colours to use for each row. 
    477478 
    478479    ``expand_to_fit=True``: boolean or integer 
     
    501502    if not isinstance(min_widths, dict): 
    502503        min_widths = dict(enumerate(min_widths or [])) 
    503     min_widths = dict([(k, v) for k, v in min_widths.items()]) 
    504504 
    505505    # Column widths 
     
    517517    # Scale columns to fit 
    518518    if width > term_width or expand_to_fit: 
    519         scale = float(term_width) / width 
    520         widths = [max(1, int(w * scale)) for w in widths] 
     519        scale = float(term_width - sum(min_widths.values())) / width 
     520        widths = [max(int(w * scale), min_widths.get(i, 1)) 
     521                  for i, w in enumerate(widths)] 
    521522 
    522523    row_alt = -1