From: Drew Fisher Date: Mon, 19 Mar 2012 05:30:03 +0000 (-0700) Subject: Make things more Pythonic. X-Git-Url: http://git.zarvox.org/%24c%5B5%5D?a=commitdiff_plain;h=3ae648ecec0c96bb9e30854ed4ab52b7cf78ebd8;p=shortlog.git Make things more Pythonic. Signed-off-by: Drew Fisher --- diff --git a/shortlog.py b/shortlog.py index 56a3e0f..16dde4b 100644 --- a/shortlog.py +++ b/shortlog.py @@ -8,6 +8,9 @@ import smtplib import hashlib pwd = os.path.dirname( os.path.realpath( __file__ ) ) +entriesdir = os.path.join(pwd, "entries") +commentsdir = os.path.join(pwd, "comments") +templatesdir = os.path.join(pwd, "templates") web.config.debug = True @@ -51,7 +54,7 @@ app = web.application(urls, globals()) # read the paragraphs from a file def readFile(filepath): f = open(filepath) - lines = map(str.strip, f.readlines()) + lines = [l.strip() for l in f.readlines()] return makeParas(lines) def loadComment(filepath): @@ -68,7 +71,7 @@ def loadComment(filepath): return (nameline, emailline, websiteline, commentbody, timestamp, gravatar) def getCommentFiles(date): # Returns a list of paths to comment files associated with date - filelist = filter( lambda x: re.match(date, x), os.listdir(pwd + "/comments")) + filelist = [x for x in os.listdir(commentsdir) if re.match(date, x)] return filelist # Collect lines into paragraph blocks. Returns a list of strings, each containing a well-formed HTML block. @@ -85,55 +88,53 @@ def makeParas(lines): paragraphs.append("\n".join(thispara)) # wrap paragraphs in

if they aren't other HTML tags that don't want to be wrapped in

tags - return map( lambda x: x if "

    " in x or "
      " in x or "
      " in x or "" in x or "
      " in x or "
      " in x or "