#!/usr/bin/python # -*- coding: iso-8859-1 -*- # runxslt.py # # Copyright © 2000, 2004 Carey Evans. # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and # that both that copyright notice and this permission notice appear in # supporting documentation. """usage: runslt.py [-a] Process the sitemap file, and update all the pages listed where the source file is newer than the generated file. If the -a option is given, update all the pages unconditionally. """ import sys, os, getopt import sitemap, walker def usage(msg=None): if msg: pgm = os.path.basename(sys.argv[0]) sys.stderr.write('%s: %s\n\n' % (pgm, msg)) sys.stderr.write(__doc__) sys.exit(1) def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'a') except getopt.error, e: usage(e) if len(args) != 2: usage('sitemap and output directory must be given') opt_all = 0 for option in opts: if option[0] == '-a': opt_all = 1 mappath = os.path.abspath(args[0]) map = sitemap.parse(mappath) srcdir = os.path.dirname(mappath) dstdir = os.path.abspath(args[1]) build = walker.PageWalker(srcdir, dstdir, opt_all) build.process(map.all_dirs()) if __name__ == '__main__': main()