column_aliases = {
    'release_year': 'year',
    'platforms': 'owned',
}

def alias_replace(col):
    if col in column_aliases:
        return column_aliases[col]
    return col

column_format = {
    'title': '<40.40',
    'release_year': '>4',
    'linux': '>5',
    'couch': '>5',
    'play_more': '>4',
    'via': '<20.20',
    'platforms': '<20.20',
    'started': '>10.10',
    'outcome': '>10.10',
}

def format_record(record, columns):
    sections = []

    for c in columns:
        if c in column_format:
            sections.append('{%s:%s}' % (c, column_format[c]))
        else:
            sections.append('{%s}' % (c,))

    output = '  '.join(sections).format(**record)
    return output

def prepend_num(string, num_digits, num = None):
    line = [] 
    if num is None:
        line.append(' ' * (num_digits + 1))
    else:
        tmp = '{0:<%i.%i}' % (num_digits+1, num_digits+1)
        line.append(tmp.format(str(num)))
    line.append(string)
    return ''.join(line)

def format_records(records, columns, header=False, nums=False):
    output = []
    num_digits = int(len(records) / 10) + 1

    if header:
        col_record = {c: alias_replace(c) for c in columns}
        line = format_record(col_record, columns)
        if nums:
            line = prepend_num(line, num_digits)
        output.append('\033[1m' + line + '\033[0m')

    for i, r in enumerate(records):
        line = format_record(r, columns)
        if nums:
            line = prepend_num(line, num_digits, i+1)
        output.append(line)

    return '\n'.join(output)


@@ -1,20 +1,33 @@
+import math%0A%0A
 column_aliases = %7B%0A 
@@ -893,17 +893,17 @@
 _digits+
-1
+2
 , num_di
@@ -907,17 +907,17 @@
 _digits+
-1
+2
 )%0A      
@@ -1103,16 +1103,27 @@
 s = int(
+math.log10(
 len(reco
@@ -1130,17 +1130,11 @@
 rds)
- / 10) + 
+))+
 1%0A%0A 

Fix bug causing extra padding for numbers