#!/usr/bin/env python """ todo.cgi - Find @@ items in a site License: GPL 2; share and enjoy! Author: Sean B. Palmer, inamidst.com @@ Ignore list --- Todo Items

Todo Items

Also: source code.

%s
Sean B. Palmer
""" import cgitb; cgitb.enable() import sys, os, re, itertools import cgiutil as cgiu suffixen = ('.html', '.txt', '.cgi') s_todo = r'(?sm)@@[ \n].+?(?:\.(?=[ \n<])|\?(?=[ \n<])|.(?=<)|\n\n)' r_todo = re.compile(s_todo) def getTodos(fn, path=None): if path is None: path = fn result = ['', '']) return result def todo(site=None): if site is None: site = os.environ.get('DOCUMENT_ROOT') or '/web/inamidst.com' if site.endswith('/'): prefix = '/' else: prefix = '' robotstxt = os.path.join(site, 'robots.txt') if os.path.exists(robotstxt): rp = cgiu.RobotsTxt(fn=robotstxt) else: rp = None result = [] for (dirpath, dirnames, filenames) in os.walk(site): for name in filenames: fn = os.path.join(dirpath, name) path = prefix + fn[len(site):] if (not rp) or rp.fetchable(path): if cgiu.any(suffixen, fn.endswith): result.extend(getTodos(fn, path)) i = __doc__.find('---') cgiu.serve(200, __doc__[i+3:] % '\n'.join(result)) def main(): if cgiu.method == 'GET': todo() else: cgiu.serve(501, "

Only GET is supported.

\n") if __name__=="__main__": main()