From 59b3fe427237302e94de3e16192b8a258b1fc4be Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Thu, 10 Dec 2009 15:19:31 +0100 Subject: Added precompiled regexp for commentfile parsing --- blogthon.cgi | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/blogthon.cgi b/blogthon.cgi index e257612..16e6e5d 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -22,7 +22,9 @@ import cgi, os, time, glob, re, md5, sys, random, smtplib import ConfigParser # A wonderful place for doing some regexp ;) -no_break = re.compile('^\s*(|||||||).*$') +no_break = re.compile('^\s*(|||||||).*$') +line_start_hyphen = re.compile('^-.*$') +line_start_plus = re.compile('^\+.*$') def generate_uuid(string): string_md5sum = md5.new(string).hexdigest() @@ -374,7 +376,7 @@ else: print '
' print '
    ' for entry in entries: - date = time.strftime("%m%Y", entry[0]) + date = time.strftime("%m%Y", entry[0]) date_display = time.strftime("%h %Y", entry[0]) if not olddate == date: print '
  • ' + date_display + '
  • ' @@ -409,6 +411,7 @@ else: print '
    ' print '' + # Staticpage if static_display != "": content = open(staticpages_dir + static_display, "r") @@ -417,7 +420,7 @@ else: print '
    ' print '

    ' for line in content: - if re.match(no_break, line): + if no_break.match(line): print ' ' + line.strip() else: print ' ' + line.strip() + '
    ' @@ -431,6 +434,7 @@ else: print '

    ' print '' content.close() + # Entry else: entry_counter = 0 @@ -453,7 +457,7 @@ else: print ' ' print '
    ' for line in content: - if re.match(no_break, line): + if no_break.match(line): print ' ' + line.strip() else: print ' ' + line.strip() + '
    ' @@ -480,7 +484,7 @@ else: label_count = 0 for line in comments_content: - if re.search("^-", line): + if line_start_hyphen.match(line): if notfirstline == 1: print '
    ' print '
    ' @@ -492,7 +496,7 @@ else: print ' ' print '
    ' + line.split(".", 1)[1].strip() + '
    ' - elif re.search("^\+", line): + elif line_start_plus.match(line): print '
    ' + line.split(".", 1)[1].strip() + '
    ' print '
    ' else: -- cgit v1.2.3