'Truncates a filename so that
somelongfilename.htm
becomes:
some...htm
as it truncates around the extension.'

def truncate(self, filename, pre_length=15, post_length=10, ellipsis=u'..'):

    (root, ext) = os.path.splitext(filename)
    if (len(root) > pre_length):
        root = (root[:pre_length] + ellipsis)
    if (len(ext) > post_length):
        ext = (ext[:post_length] + ellipsis)
    return (root + ext)
