#!/usr/local/bin/python """pystyler.py: A Web style generator program. Author: John W. Shipman (john@nmt.edu), Applications Specialist, New Mexico Tech Computer Center, Socorro, NM 87801 Written: July 1999 $Revision: 1.25 $ $Date: 2002/08/01 07:17:35 $ Revision history: 2.03 2002-08-01: Previously, PyStyler did not allow hyphens to be used in attribute names. However, when XSLT generates a file, it always includes a tag like ", so clearly hyphens *should* be allowed. 2.02 2001-01-16: Fixed a bug found by Hedges. If a page links to an anchor elsewhere in itself, such as in page foo.g, the result link had href=".html#anch" instead of href="foo.html#anch". 2.01 2000-06-06: - Added "-u" option to check that all page titles are unique. - Force page rewrite if Plan file is newer than .html file. - Report number of pages rewritten. 2.00 Complete rewrite in Python, May 2000 1.00 Original version in Icon, Oct.--Nov. 1995 """ EXTERNAL_VERSION = "2.03" PROGRAM_NAME = "PyStyler" #---------------------------------------------------------------- # Imports #---------------------------------------------------------------- import sys # Standard system functions import getopt # Command line argument processing functions import string # Standard string functions import os # For pathname operations import stat # For filename status tuple interpretation #-- # From author's generic Python library #-- sys.path.insert(0, "/u/john/tcc/python/lib") import log # Author's error logging object import pathinfo # Takes snapshots of file status #-- # Other modules in primary source directory #-- sys.path.insert(0, "/u/john/projects/pystyler") from pathmap import * # Represents the PathMap file from plan import * # Represents the Plan file from template import * # Template and TmplPool objects from body import * # Body (input) files #---------------------------------------------------------------- # Manifest constants #---------------------------------------------------------------- #-- # Command line options #-- FORCE_ARG = "f" # -f: Force writing of all output files UNIQUE_ARG = "u" # -u: Report non-unique page titles WRITE_ARG = "w" # -w: Write to specified directory tree NAV_ARG = "n" # -n: Generate navigational shock report #-- # File names and extensions #-- PATH_MAP_NAME = "PathMap" # Source for PathMap object PLAN_NAME = "Plan" # Source for Plan object LOG_NAME = "webstyler.log" # Error log file #-- # The next two pertain to the `navigational shock report' #-- INDENT_PER_DEPTH = 3 # Amount to indent each outline level VAR_INDENT = 4 # Amount to indent link variants # - - - VERIFICATION FUNCTIONS - - - #---------------------------------------------------------------- # These defines are used in Cleanroom verification. #---------------------------------------------------------------- # all-output-pages(args, pathMap, plan) == # the files corresponding to the set of pages P named in plan, # where each file's name is output-path(P, args, pathMap) #-- # This is the set of output pages to be written if the force (-f) # option is given. #---------------------------------------------------------------- # all-subtree-pages(topic, force, outRoot, pathMap, plan) == # for all topics T at or under topic in the topic tree, the # set of output files named output-path(T, outRoot, pathMap, plan) #-- # The set of pages rewritten if the FORCE_ARG is not given on the # command line. #---------------------------------------------------------------- # effective-template(topic, contents) == # if contents includes a