A tool to create a xhtml file quickly

#!/usr/bin/env python2.2

import getopt
import sys

opts,args = getopt.getopt( sys.argv[1:], 'stfhT:C:l:c:' )
opts = dict( opts )

def usage():
  print """
    Usage: ... [-f | -s | -t ] >file.html
    
             Doctypes:
                -t : transitional (default)
                -s : strict
                -f : frames
                
             Misc:
                -T "title"        : Titel der Webseite
                -C "css filename" : CSS-Zeile einbauen
                -l "de"      : Sprache
                -c "charset" : charset (default: charset iso8859-15)
  """

if opts.has_key('-h'):
  usage()
  sys.exit(1)
  
dtd_strict = '"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"'
dtd_frames = '"-//W3C//DTD XHTML 1.0 Transisitonal//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"'
dtd_trans  = '"-//W3C//DTD XHTML 1.0 Frames//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frames.dtd"'

title = opts.get( '-T', '' )

dtd_type = dtd_trans
if opts.get('-s', None) != None:
  dtd_type = dtd_strict
if opts.get('-f', None) != None:
  dtd_type = dtd_frames
  
charset = opts.get('-c', 'iso8859-15')

lang    = opts.get('-l', 'de')

stylesheet = ''
if opts.get('-C', None) != None:
  stylesheet = '<link rel="StyleSheet" href="%s" type="text/css">\n' % ( opts['-C'], ) 


print """<!DOCTYPE html PUBLIC %s>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="%s" lang="%s">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=%s">
  %s<title>%s</title>
</head>
<body bgcolor="white">

</body>
</html>
""" % (dtd_type, lang, lang, charset, stylesheet, title )