From 3b8dc6b9595a3e2abfbc2d031c09635f28677c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Thu, 8 Apr 2010 00:50:57 +0200 Subject: Added changelog --- helper.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'helper.py') diff --git a/helper.py b/helper.py index 7f97824..1828b5e 100644 --- a/helper.py +++ b/helper.py @@ -1,6 +1,8 @@ import web import os import Image +import markdown +import cStringIO opj = os.path.join @@ -51,3 +53,27 @@ def getImages (path, tmpPath, size): desc = d.read().strip() yield (imgUrl, thumbUrl, desc) + +def getChangelogs (path): + if path[0] != '/': path = '/' + path + appPath = appdir(path[1:]) + + md = markdown.Markdown(safe_mode = "escape", output_format = "html4") + + def ver_to_int (x): + x = x.split(".")[:-1] + + pow = 3 + res = 0 + for i in x: + res += int(i) ** pow + pow -= 1 + return res + + for f in sorted((f for f in os.listdir(appPath) if f.endswith(".txt") and not f[0] == "."), key = ver_to_int, reverse = True): + io = cStringIO.StringIO() + md.convertFile(input = opj(appPath, f), output = io, encoding="utf8") + html = io.getvalue() + io.close() + + yield (html, f[:-4]) -- cgit v1.2.3