#! /usr/local/bin/python """ Little script to sort comments by time submitted & then display them. """ import sys sys.path.append('/u/t/articles') from comments_config import load_comments, wfiles_cgi comments_dict = load_comments() all_comments = [] for k, v in comments_dict.items(): all_comments.extend([(k, c) for c in v]) def sort_comments_by_time(a, b): c1 = a[1] c2 = b[1] return -cmp(c1.date, c2.date) all_comments.sort(sort_comments_by_time) def make_path(p): full_path = wfiles_cgi+ '/' + p return '
' % (full_path, full_path,) comment_text = [ make_path(path) + c.format() for (path, c) in all_comments ] s = "