#!/usr/bin/env python """ entries.py - Juno Entries Module Copyright 2008, Sean B. Palmer, inamidst.com Licensed under the Eiffel Forum License 2. http://inamidst.com/whits/code/juno/ """ import os, glob, time def entries(): # yield URI, updated, title, content now = time.time() recent = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(now - 3600)) potential = [] for fn in glob.glob('2*/*.html') + glob.glob('2*/*/*.html'): mtime = os.path.getmtime(fn) path = fn[:-5].lstrip('./') if (path[-3] == '/') and (path[-6] == '/'): updated = path.replace('/', '-') + 'T23:59:59Z' else: updated = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(mtime)) if updated > recent: continue potential.append((updated, fn, path)) for updated, fn, path in sorted(potential, reverse=True): f = open(fn) first = f.next() if first.startswith(''): uri = 'http://inamidst.com/whits/' + path title = f.next().rstrip('\r\n')[7:-8] content = [] section = False for line in f: if line.startswith('
'): section = True elif line.startswith('
'): break elif section: line = line.replace(']]>', ']]>]]>