<s> import os <EOL> import sys <EOL> import string <EOL> import re <EOL> MAGIC = '<STR_LIT>' <EOL> cmprog = re . compile ( '<STR_LIT>' ) <EOL> blprog = re . compile ( '<STR_LIT>' ) <EOL> kwprog = re . compile ( '<STR_LIT>' ) <EOL> spprog = re . compile ( '<STR_LIT>' ) <EOL> miprog = re . compile ( '<STR_LIT>' ) <EOL> class HTMLNode : <EOL> """<STR_LIT>""" <EOL> DOCTYPE = '<STR_LIT>' <EOL> type = <NUM_LIT:0> <EOL> cont = '<STR_LIT>' <EOL> epilogue = '<STR_LIT>' <EOL> def __init__ ( self , dir , name , topname , title , next , prev , up ) : <EOL> self . dirname = dir <EOL> self . name = name <EOL> if topname : <EOL> self . topname = topname <EOL> else : <EOL> self . topname = name <EOL> self . title = title <EOL> self . next = next <EOL> self . prev = prev <EOL> self . up = up <EOL> self . lines = [ ] <EOL> def write ( self , * lines ) : <EOL> map ( self . lines . append , lines ) <EOL> def flush ( self ) : <EOL> fp = open ( self . dirname + '<STR_LIT:/>' + makefile ( self . name ) , '<STR_LIT:w>' ) <EOL> fp . write ( self . prologue ) <EOL> fp . write ( self . text ) <EOL> fp . write ( self . epilogue ) <EOL> fp . close ( ) <EOL> def link ( self , label , nodename , rel = None , rev = None ) : <EOL> if nodename : <EOL> if nodename . lower ( ) == '<STR_LIT>' : <EOL> addr = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> else : <EOL> addr = makefile ( nodename ) <EOL> title = '<STR_LIT>' % nodename <EOL> self . write ( label , '<STR_LIT>' , addr , '<STR_LIT:">' , rel and ( '<STR_LIT>' + rel ) or "<STR_LIT>" , rev and ( '<STR_LIT>' + rev ) or "<STR_LIT>" , title , '<STR_LIT:>>' , nodename , '<STR_LIT>' ) <EOL> def finalize ( self ) : <EOL> length = len ( self . lines ) <EOL> self . text = '<STR_LIT>' . join ( self . lines ) <EOL> self . lines = [ ] <EOL> self . open_links ( ) <EOL> self . output_links ( ) <EOL> self . close_links ( ) <EOL> links = '<STR_LIT>' . join ( self . lines ) <EOL> self . lines = [ ] <EOL> self . prologue = ( <EOL> self . DOCTYPE + <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' + self . title + '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> + makefile ( self . next ) + '<STR_LIT>' + self . next + '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> + makefile ( self . prev ) + '<STR_LIT>' + self . prev + '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> + makefile ( self . up ) + '<STR_LIT>' + self . up + '<STR_LIT>' <EOL> '<STR_LIT>' + <EOL> links ) <EOL> if length > <NUM_LIT:20> : <EOL> self . epilogue = '<STR_LIT>' % links <EOL> def open_links ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> def close_links ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> def output_links ( self ) : <EOL> if self . cont != self . next : <EOL> self . link ( '<STR_LIT>' , self . cont ) <EOL> self . link ( '<STR_LIT>' , self . next , rel = '<STR_LIT>' ) <EOL> self . link ( '<STR_LIT>' , self . prev , rel = '<STR_LIT>' ) <EOL> self . link ( '<STR_LIT>' , self . up , rel = '<STR_LIT>' ) <EOL> if self . name < > self . topname : <EOL> self . link ( '<STR_LIT>' , self . topname ) <EOL> class HTML3Node ( HTMLNode ) : <EOL> DOCTYPE = '<STR_LIT>' <EOL> def open_links ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> def close_links ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> class TexinfoParser : <EOL> COPYRIGHT_SYMBOL = "<STR_LIT>" <EOL> FN_ID_PATTERN = "<STR_LIT>" <EOL> FN_SOURCE_PATTERN = '<STR_LIT>' '<STR_LIT>' + FN_ID_PATTERN + '<STR_LIT>' <EOL> FN_TARGET_PATTERN = '<STR_LIT>' '<STR_LIT>' + FN_ID_PATTERN + '<STR_LIT>' <EOL> FN_HEADER = '<STR_LIT>' '<STR_LIT>' <EOL> Node = HTMLNode <EOL> def __init__ ( self ) : <EOL> self . unknown = { } <EOL> self . filenames = { } <EOL> self . debugging = <NUM_LIT:0> <EOL> self . print_headers = <NUM_LIT:0> <EOL> self . nodefp = None <EOL> self . nodelineno = <NUM_LIT:0> <EOL> self . links = None <EOL> self . savetext = None <EOL> self . savestack = [ ] <EOL> self . htmlhelp = None <EOL> self . dirname = '<STR_LIT>' <EOL> self . includedir = '<STR_LIT:.>' <EOL> self . nodename = '<STR_LIT>' <EOL> self . topname = '<STR_LIT>' <EOL> self . title = '<STR_LIT>' <EOL> self . resetindex ( ) <EOL> self . contents = [ ] <EOL> self . numbering = [ ] <EOL> self . nofill = <NUM_LIT:0> <EOL> self . values = { '<STR_LIT:html>' : <NUM_LIT:1> } <EOL> self . stackinfo = { } <EOL> self . footnotes = [ ] <EOL> self . itemarg = None <EOL> self . itemnumber = None <EOL> self . itemindex = None <EOL> self . node = None <EOL> self . nodestack = [ ] <EOL> self . cont = <NUM_LIT:0> <EOL> self . includedepth = <NUM_LIT:0> <EOL> def sethtmlhelp ( self , htmlhelp ) : <EOL> self . htmlhelp = htmlhelp <EOL> def setdirname ( self , dirname ) : <EOL> self . dirname = dirname <EOL> def setincludedir ( self , includedir ) : <EOL> self . includedir = includedir <EOL> def parse ( self , fp ) : <EOL> line = fp . readline ( ) <EOL> lineno = <NUM_LIT:1> <EOL> while line and ( line [ <NUM_LIT:0> ] == '<STR_LIT:%>' or blprog . match ( line ) ) : <EOL> line = fp . readline ( ) <EOL> lineno = lineno + <NUM_LIT:1> <EOL> if line [ : len ( MAGIC ) ] < > MAGIC : <EOL> raise SyntaxError , '<STR_LIT>' % ( MAGIC , ) <EOL> self . parserest ( fp , lineno ) <EOL> def parserest ( self , fp , initial_lineno ) : <EOL> lineno = initial_lineno <EOL> self . done = <NUM_LIT:0> <EOL> self . skip = <NUM_LIT:0> <EOL> self . stack = [ ] <EOL> accu = [ ] <EOL> while not self . done : <EOL> line = fp . readline ( ) <EOL> self . nodelineno = self . nodelineno + <NUM_LIT:1> <EOL> if not line : <EOL> if accu : <EOL> if not self . skip : self . process ( accu ) <EOL> accu = [ ] <EOL> if initial_lineno > <NUM_LIT:0> : <EOL> print '<STR_LIT>' <EOL> break <EOL> lineno = lineno + <NUM_LIT:1> <EOL> mo = cmprog . match ( line ) <EOL> if mo : <EOL> a , b = mo . span ( <NUM_LIT:1> ) <EOL> cmd = line [ a : b ] <EOL> if cmd in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> accu . append ( line ) <EOL> else : <EOL> if accu : <EOL> if not self . skip : <EOL> self . process ( accu ) <EOL> accu = [ ] <EOL> self . command ( line , mo ) <EOL> elif blprog . match ( line ) and '<STR_LIT>' not in self . stack and '<STR_LIT>' not in self . stack : <EOL> if accu : <EOL> if not self . skip : <EOL> self . process ( accu ) <EOL> if self . nofill : <EOL> self . write ( '<STR_LIT:\n>' ) <EOL> else : <EOL> self . write ( '<STR_LIT>' ) <EOL> accu = [ ] <EOL> else : <EOL> accu . append ( line ) <EOL> if self . skip : <EOL> print '<STR_LIT>' <EOL> if self . stack : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' , self . stack <EOL> if self . includedepth == <NUM_LIT:0> : <EOL> while self . nodestack : <EOL> self . nodestack [ - <NUM_LIT:1> ] . finalize ( ) <EOL> self . nodestack [ - <NUM_LIT:1> ] . flush ( ) <EOL> del self . nodestack [ - <NUM_LIT:1> ] <EOL> def startsaving ( self ) : <EOL> if self . savetext < > None : <EOL> self . savestack . append ( self . savetext ) <EOL> self . savetext = '<STR_LIT>' <EOL> def collectsavings ( self ) : <EOL> savetext = self . savetext <EOL> if len ( self . savestack ) > <NUM_LIT:0> : <EOL> self . savetext = self . savestack [ - <NUM_LIT:1> ] <EOL> del self . savestack [ - <NUM_LIT:1> ] <EOL> else : <EOL> self . savetext = None <EOL> return savetext or '<STR_LIT>' <EOL> def write ( self , * args ) : <EOL> try : <EOL> text = '<STR_LIT>' . join ( args ) <EOL> except : <EOL> print args <EOL> raise TypeError <EOL> if self . savetext < > None : <EOL> self . savetext = self . savetext + text <EOL> elif self . nodefp : <EOL> self . nodefp . write ( text ) <EOL> elif self . node : <EOL> self . node . write ( text ) <EOL> def endnode ( self ) : <EOL> if self . savetext < > None : <EOL> print '<STR_LIT>' <EOL> dummy = self . collectsavings ( ) <EOL> if self . footnotes : <EOL> self . writefootnotes ( ) <EOL> if self . nodefp : <EOL> if self . nodelineno > <NUM_LIT:20> : <EOL> self . write ( '<STR_LIT>' ) <EOL> [ name , next , prev , up ] = self . nodelinks [ : <NUM_LIT:4> ] <EOL> self . link ( '<STR_LIT>' , next ) <EOL> self . link ( '<STR_LIT>' , prev ) <EOL> self . link ( '<STR_LIT>' , up ) <EOL> if self . nodename < > self . topname : <EOL> self . link ( '<STR_LIT>' , self . topname ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . nodefp . close ( ) <EOL> self . nodefp = None <EOL> elif self . node : <EOL> if not self . cont and ( not self . node . type or ( self . node . next and self . node . prev and self . node . up ) ) : <EOL> self . node . finalize ( ) <EOL> self . node . flush ( ) <EOL> else : <EOL> self . nodestack . append ( self . node ) <EOL> self . node = None <EOL> self . nodename = '<STR_LIT>' <EOL> def process ( self , accu ) : <EOL> if self . debugging > <NUM_LIT:1> : <EOL> print '<STR_LIT:!>' * self . debugging , '<STR_LIT>' , self . skip , self . stack , <EOL> if accu : print accu [ <NUM_LIT:0> ] [ : <NUM_LIT:30> ] , <EOL> if accu [ <NUM_LIT:0> ] [ <NUM_LIT:30> : ] or accu [ <NUM_LIT:1> : ] : print '<STR_LIT>' , <EOL> print <EOL> if self . inmenu ( ) : <EOL> for line in accu : <EOL> mo = miprog . match ( line ) <EOL> if not mo : <EOL> line = line . strip ( ) + '<STR_LIT:\n>' <EOL> self . expand ( line ) <EOL> continue <EOL> bgn , end = mo . span ( <NUM_LIT:0> ) <EOL> a , b = mo . span ( <NUM_LIT:1> ) <EOL> c , d = mo . span ( <NUM_LIT:2> ) <EOL> e , f = mo . span ( <NUM_LIT:3> ) <EOL> g , h = mo . span ( <NUM_LIT:4> ) <EOL> label = line [ a : b ] <EOL> nodename = line [ c : d ] <EOL> if nodename [ <NUM_LIT:0> ] == '<STR_LIT::>' : nodename = label <EOL> else : nodename = line [ e : f ] <EOL> punct = line [ g : h ] <EOL> self . write ( '<STR_LIT>' , <EOL> makefile ( nodename ) , <EOL> '<STR_LIT>' , nodename , <EOL> '<STR_LIT>' , punct , '<STR_LIT:\n>' ) <EOL> self . htmlhelp . menuitem ( nodename ) <EOL> self . expand ( line [ end : ] ) <EOL> else : <EOL> text = '<STR_LIT>' . join ( accu ) <EOL> self . expand ( text ) <EOL> def inmenu ( self ) : <EOL> stack = self . stack <EOL> while stack and stack [ - <NUM_LIT:1> ] in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> try : <EOL> if self . stackinfo [ len ( stack ) ] : <EOL> return <NUM_LIT:0> <EOL> except KeyError : <EOL> pass <EOL> stack = stack [ : - <NUM_LIT:1> ] <EOL> return ( stack and stack [ - <NUM_LIT:1> ] == '<STR_LIT>' ) <EOL> def expand ( self , text ) : <EOL> stack = [ ] <EOL> i = <NUM_LIT:0> <EOL> n = len ( text ) <EOL> while i < n : <EOL> start = i <EOL> mo = spprog . search ( text , i ) <EOL> if mo : <EOL> i = mo . start ( ) <EOL> else : <EOL> self . write ( text [ start : ] ) <EOL> break <EOL> self . write ( text [ start : i ] ) <EOL> c = text [ i ] <EOL> i = i + <NUM_LIT:1> <EOL> if c == '<STR_LIT:\n>' : <EOL> self . write ( '<STR_LIT:\n>' ) <EOL> continue <EOL> if c == '<STR_LIT:<>' : <EOL> self . write ( '<STR_LIT>' ) <EOL> continue <EOL> if c == '<STR_LIT:>>' : <EOL> self . write ( '<STR_LIT>' ) <EOL> continue <EOL> if c == '<STR_LIT:&>' : <EOL> self . write ( '<STR_LIT>' ) <EOL> continue <EOL> if c == '<STR_LIT:{>' : <EOL> stack . append ( '<STR_LIT>' ) <EOL> continue <EOL> if c == '<STR_LIT:}>' : <EOL> if not stack : <EOL> print '<STR_LIT>' <EOL> self . write ( '<STR_LIT:}>' ) <EOL> continue <EOL> cmd = stack [ - <NUM_LIT:1> ] <EOL> del stack [ - <NUM_LIT:1> ] <EOL> try : <EOL> method = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> self . unknown_close ( cmd ) <EOL> continue <EOL> method ( ) <EOL> continue <EOL> if c < > '<STR_LIT:@>' : <EOL> raise RuntimeError , '<STR_LIT>' % c <EOL> start = i <EOL> while i < n and text [ i ] in string . ascii_letters : i = i + <NUM_LIT:1> <EOL> if i == start : <EOL> i = i + <NUM_LIT:1> <EOL> c = text [ start : i ] <EOL> if c == '<STR_LIT::>' : <EOL> pass <EOL> else : <EOL> self . write ( c ) <EOL> continue <EOL> cmd = text [ start : i ] <EOL> if i < n and text [ i ] == '<STR_LIT:{>' : <EOL> i = i + <NUM_LIT:1> <EOL> stack . append ( cmd ) <EOL> try : <EOL> method = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> self . unknown_open ( cmd ) <EOL> continue <EOL> method ( ) <EOL> continue <EOL> try : <EOL> method = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> self . unknown_handle ( cmd ) <EOL> continue <EOL> method ( ) <EOL> if stack : <EOL> print '<STR_LIT>' , stack <EOL> def unknown_open ( self , cmd ) : <EOL> print '<STR_LIT>' + cmd + '<STR_LIT>' <EOL> cmd = cmd + '<STR_LIT:{>' <EOL> self . write ( '<STR_LIT:@>' , cmd ) <EOL> if not self . unknown . has_key ( cmd ) : <EOL> self . unknown [ cmd ] = <NUM_LIT:1> <EOL> else : <EOL> self . unknown [ cmd ] = self . unknown [ cmd ] + <NUM_LIT:1> <EOL> def unknown_close ( self , cmd ) : <EOL> print '<STR_LIT>' + cmd + '<STR_LIT>' <EOL> cmd = '<STR_LIT:}>' + cmd <EOL> self . write ( '<STR_LIT:}>' ) <EOL> if not self . unknown . has_key ( cmd ) : <EOL> self . unknown [ cmd ] = <NUM_LIT:1> <EOL> else : <EOL> self . unknown [ cmd ] = self . unknown [ cmd ] + <NUM_LIT:1> <EOL> def unknown_handle ( self , cmd ) : <EOL> print '<STR_LIT>' + cmd <EOL> self . write ( '<STR_LIT:@>' , cmd ) <EOL> if not self . unknown . has_key ( cmd ) : <EOL> self . unknown [ cmd ] = <NUM_LIT:1> <EOL> else : <EOL> self . unknown [ cmd ] = self . unknown [ cmd ] + <NUM_LIT:1> <EOL> def handle_noindent ( self ) : pass <EOL> def handle_refill ( self ) : pass <EOL> def do_include ( self , args ) : <EOL> file = args <EOL> file = os . path . join ( self . includedir , file ) <EOL> try : <EOL> fp = open ( file , '<STR_LIT:r>' ) <EOL> except IOError , msg : <EOL> print '<STR_LIT>' , repr ( file ) <EOL> return <EOL> print '<STR_LIT:!>' * self . debugging , '<STR_LIT>' , repr ( file ) <EOL> save_done = self . done <EOL> save_skip = self . skip <EOL> save_stack = self . stack <EOL> self . includedepth = self . includedepth + <NUM_LIT:1> <EOL> self . parserest ( fp , <NUM_LIT:0> ) <EOL> self . includedepth = self . includedepth - <NUM_LIT:1> <EOL> fp . close ( ) <EOL> self . done = save_done <EOL> self . skip = save_skip <EOL> self . stack = save_stack <EOL> print '<STR_LIT:!>' * self . debugging , '<STR_LIT>' , repr ( file ) <EOL> def open_dmn ( self ) : pass <EOL> def close_dmn ( self ) : pass <EOL> def open_dots ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_dots ( self ) : pass <EOL> def open_bullet ( self ) : pass <EOL> def close_bullet ( self ) : pass <EOL> def open_TeX ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_TeX ( self ) : pass <EOL> def handle_copyright ( self ) : self . write ( self . COPYRIGHT_SYMBOL ) <EOL> def open_copyright ( self ) : self . write ( self . COPYRIGHT_SYMBOL ) <EOL> def close_copyright ( self ) : pass <EOL> def open_minus ( self ) : self . write ( '<STR_LIT:->' ) <EOL> def close_minus ( self ) : pass <EOL> def open_exclamdown ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_exclamdown ( self ) : pass <EOL> def open_questiondown ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_questiondown ( self ) : pass <EOL> def open_aa ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_aa ( self ) : pass <EOL> def open_AA ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_AA ( self ) : pass <EOL> def open_ae ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_ae ( self ) : pass <EOL> def open_AE ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_AE ( self ) : pass <EOL> def open_o ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_o ( self ) : pass <EOL> def open_O ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_O ( self ) : pass <EOL> def open_ss ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_ss ( self ) : pass <EOL> def open_oe ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_oe ( self ) : pass <EOL> def open_OE ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_OE ( self ) : pass <EOL> def open_l ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_l ( self ) : pass <EOL> def open_L ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_L ( self ) : pass <EOL> def open_result ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_result ( self ) : pass <EOL> def open_expansion ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_expansion ( self ) : pass <EOL> def open_print ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_print ( self ) : pass <EOL> def open_error ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_error ( self ) : pass <EOL> def open_equiv ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_equiv ( self ) : pass <EOL> def open_point ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_point ( self ) : pass <EOL> def open_pxref ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . startsaving ( ) <EOL> def close_pxref ( self ) : <EOL> self . makeref ( ) <EOL> def open_xref ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . startsaving ( ) <EOL> def close_xref ( self ) : <EOL> self . makeref ( ) <EOL> def open_ref ( self ) : <EOL> self . startsaving ( ) <EOL> def close_ref ( self ) : <EOL> self . makeref ( ) <EOL> def open_inforef ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . startsaving ( ) <EOL> def close_inforef ( self ) : <EOL> text = self . collectsavings ( ) <EOL> args = [ s . strip ( ) for s in text . split ( '<STR_LIT:U+002C>' ) ] <EOL> while len ( args ) < <NUM_LIT:3> : args . append ( '<STR_LIT>' ) <EOL> node = args [ <NUM_LIT:0> ] <EOL> file = args [ <NUM_LIT:2> ] <EOL> self . write ( '<STR_LIT>' , file , '<STR_LIT>' , node , '<STR_LIT>' ) <EOL> def makeref ( self ) : <EOL> text = self . collectsavings ( ) <EOL> args = [ s . strip ( ) for s in text . split ( '<STR_LIT:U+002C>' ) ] <EOL> while len ( args ) < <NUM_LIT:5> : args . append ( '<STR_LIT>' ) <EOL> nodename = label = args [ <NUM_LIT:0> ] <EOL> if args [ <NUM_LIT:2> ] : label = args [ <NUM_LIT:2> ] <EOL> file = args [ <NUM_LIT:3> ] <EOL> title = args [ <NUM_LIT:4> ] <EOL> href = makefile ( nodename ) <EOL> if file : <EOL> href = '<STR_LIT>' + file + '<STR_LIT:/>' + href <EOL> self . write ( '<STR_LIT>' , href , '<STR_LIT>' , label , '<STR_LIT>' ) <EOL> def open_uref ( self ) : <EOL> self . startsaving ( ) <EOL> def close_uref ( self ) : <EOL> text = self . collectsavings ( ) <EOL> args = [ s . strip ( ) for s in text . split ( '<STR_LIT:U+002C>' ) ] <EOL> while len ( args ) < <NUM_LIT:2> : args . append ( '<STR_LIT>' ) <EOL> href = args [ <NUM_LIT:0> ] <EOL> label = args [ <NUM_LIT:1> ] <EOL> if not label : label = href <EOL> self . write ( '<STR_LIT>' , href , '<STR_LIT>' , label , '<STR_LIT>' ) <EOL> def open_image ( self ) : <EOL> self . startsaving ( ) <EOL> def close_image ( self ) : <EOL> self . makeimage ( ) <EOL> def makeimage ( self ) : <EOL> text = self . collectsavings ( ) <EOL> args = [ s . strip ( ) for s in text . split ( '<STR_LIT:U+002C>' ) ] <EOL> while len ( args ) < <NUM_LIT:5> : args . append ( '<STR_LIT>' ) <EOL> filename = args [ <NUM_LIT:0> ] <EOL> width = args [ <NUM_LIT:1> ] <EOL> height = args [ <NUM_LIT:2> ] <EOL> alt = args [ <NUM_LIT:3> ] <EOL> ext = args [ <NUM_LIT:4> ] <EOL> imagelocation = self . dirname + '<STR_LIT:/>' + filename <EOL> if os . path . exists ( imagelocation + '<STR_LIT>' ) : <EOL> filename += '<STR_LIT>' <EOL> elif os . path . exists ( imagelocation + '<STR_LIT>' ) : <EOL> filename += '<STR_LIT>' <EOL> elif os . path . exists ( imagelocation + '<STR_LIT>' ) : <EOL> filename += '<STR_LIT>' <EOL> else : <EOL> print "<STR_LIT>" + imagelocation <EOL> self . write ( '<STR_LIT>' , filename , '<STR_LIT:">' , width and ( '<STR_LIT>' + width + '<STR_LIT:">' ) or "<STR_LIT>" , height and ( '<STR_LIT>' + height + '<STR_LIT:">' ) or "<STR_LIT>" , alt and ( '<STR_LIT>' + alt + '<STR_LIT:">' ) or "<STR_LIT>" , '<STR_LIT>' ) <EOL> self . htmlhelp . addimage ( imagelocation ) <EOL> def open_ ( self ) : pass <EOL> def close_ ( self ) : pass <EOL> open_asis = open_ <EOL> close_asis = close_ <EOL> def open_cite ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_cite ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_code ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_code ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_t ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_t ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_dfn ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_dfn ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_emph ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_emph ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_i ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_i ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_footnote ( self ) : <EOL> id = len ( self . footnotes ) + <NUM_LIT:1> <EOL> self . write ( self . FN_SOURCE_PATTERN % { '<STR_LIT:id>' : repr ( id ) } ) <EOL> self . startsaving ( ) <EOL> def close_footnote ( self ) : <EOL> id = len ( self . footnotes ) + <NUM_LIT:1> <EOL> self . footnotes . append ( ( id , self . collectsavings ( ) ) ) <EOL> def writefootnotes ( self ) : <EOL> self . write ( self . FN_HEADER ) <EOL> for id , text in self . footnotes : <EOL> self . write ( self . FN_TARGET_PATTERN <EOL> % { '<STR_LIT:id>' : repr ( id ) , '<STR_LIT:text>' : text } ) <EOL> self . footnotes = [ ] <EOL> def open_file ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_file ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_kbd ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_kbd ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_key ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_key ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_r ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_r ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_samp ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_samp ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_sc ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_sc ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_strong ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_strong ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_b ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_b ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_var ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_var ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_w ( self ) : self . write ( '<STR_LIT>' ) <EOL> def close_w ( self ) : self . write ( '<STR_LIT>' ) <EOL> def open_url ( self ) : self . startsaving ( ) <EOL> def close_url ( self ) : <EOL> text = self . collectsavings ( ) <EOL> self . write ( '<STR_LIT>' , text , '<STR_LIT>' , text , '<STR_LIT>' ) <EOL> def open_email ( self ) : self . startsaving ( ) <EOL> def close_email ( self ) : <EOL> text = self . collectsavings ( ) <EOL> self . write ( '<STR_LIT>' , text , '<STR_LIT>' , text , '<STR_LIT>' ) <EOL> open_titlefont = open_ <EOL> close_titlefont = close_ <EOL> def open_small ( self ) : pass <EOL> def close_small ( self ) : pass <EOL> def command ( self , line , mo ) : <EOL> a , b = mo . span ( <NUM_LIT:1> ) <EOL> cmd = line [ a : b ] <EOL> args = line [ b : ] . strip ( ) <EOL> if self . debugging > <NUM_LIT:1> : <EOL> print '<STR_LIT:!>' * self . debugging , '<STR_LIT>' , self . skip , self . stack , '<STR_LIT:@>' + cmd , args <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> if not self . skip : <EOL> self . unknown_cmd ( cmd , args ) <EOL> return <EOL> self . stack . append ( cmd ) <EOL> func ( args ) <EOL> return <EOL> if not self . skip or cmd == '<STR_LIT:end>' : <EOL> func ( args ) <EOL> def unknown_cmd ( self , cmd , args ) : <EOL> print '<STR_LIT>' , '<STR_LIT:@>' + cmd , args <EOL> if not self . unknown . has_key ( cmd ) : <EOL> self . unknown [ cmd ] = <NUM_LIT:1> <EOL> else : <EOL> self . unknown [ cmd ] = self . unknown [ cmd ] + <NUM_LIT:1> <EOL> def do_end ( self , args ) : <EOL> words = args . split ( ) <EOL> if not words : <EOL> print '<STR_LIT>' <EOL> else : <EOL> cmd = words [ <NUM_LIT:0> ] <EOL> if not self . stack or self . stack [ - <NUM_LIT:1> ] < > cmd : <EOL> print '<STR_LIT>' , cmd , '<STR_LIT>' <EOL> else : <EOL> del self . stack [ - <NUM_LIT:1> ] <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> self . unknown_end ( cmd ) <EOL> return <EOL> func ( ) <EOL> def unknown_end ( self , cmd ) : <EOL> cmd = '<STR_LIT>' + cmd <EOL> print '<STR_LIT>' , '<STR_LIT:@>' + cmd <EOL> if not self . unknown . has_key ( cmd ) : <EOL> self . unknown [ cmd ] = <NUM_LIT:1> <EOL> else : <EOL> self . unknown [ cmd ] = self . unknown [ cmd ] + <NUM_LIT:1> <EOL> def do_comment ( self , args ) : pass <EOL> do_c = do_comment <EOL> def bgn_ifinfo ( self , args ) : pass <EOL> def end_ifinfo ( self ) : pass <EOL> def bgn_iftex ( self , args ) : self . skip = self . skip + <NUM_LIT:1> <EOL> def end_iftex ( self ) : self . skip = self . skip - <NUM_LIT:1> <EOL> def bgn_ignore ( self , args ) : self . skip = self . skip + <NUM_LIT:1> <EOL> def end_ignore ( self ) : self . skip = self . skip - <NUM_LIT:1> <EOL> def bgn_tex ( self , args ) : self . skip = self . skip + <NUM_LIT:1> <EOL> def end_tex ( self ) : self . skip = self . skip - <NUM_LIT:1> <EOL> def do_set ( self , args ) : <EOL> fields = args . split ( '<STR_LIT:U+0020>' ) <EOL> key = fields [ <NUM_LIT:0> ] <EOL> if len ( fields ) == <NUM_LIT:1> : <EOL> value = <NUM_LIT:1> <EOL> else : <EOL> value = '<STR_LIT:U+0020>' . join ( fields [ <NUM_LIT:1> : ] ) <EOL> self . values [ key ] = value <EOL> def do_clear ( self , args ) : <EOL> self . values [ args ] = None <EOL> def bgn_ifset ( self , args ) : <EOL> if args not in self . values . keys ( ) or self . values [ args ] is None : <EOL> self . skip = self . skip + <NUM_LIT:1> <EOL> self . stackinfo [ len ( self . stack ) ] = <NUM_LIT:1> <EOL> else : <EOL> self . stackinfo [ len ( self . stack ) ] = <NUM_LIT:0> <EOL> def end_ifset ( self ) : <EOL> try : <EOL> if self . stackinfo [ len ( self . stack ) + <NUM_LIT:1> ] : <EOL> self . skip = self . skip - <NUM_LIT:1> <EOL> del self . stackinfo [ len ( self . stack ) + <NUM_LIT:1> ] <EOL> except KeyError : <EOL> print '<STR_LIT>' , len ( self . stack ) + <NUM_LIT:1> <EOL> def bgn_ifclear ( self , args ) : <EOL> if args in self . values . keys ( ) and self . values [ args ] is not None : <EOL> self . skip = self . skip + <NUM_LIT:1> <EOL> self . stackinfo [ len ( self . stack ) ] = <NUM_LIT:1> <EOL> else : <EOL> self . stackinfo [ len ( self . stack ) ] = <NUM_LIT:0> <EOL> def end_ifclear ( self ) : <EOL> try : <EOL> if self . stackinfo [ len ( self . stack ) + <NUM_LIT:1> ] : <EOL> self . skip = self . skip - <NUM_LIT:1> <EOL> del self . stackinfo [ len ( self . stack ) + <NUM_LIT:1> ] <EOL> except KeyError : <EOL> print '<STR_LIT>' , len ( self . stack ) + <NUM_LIT:1> <EOL> def open_value ( self ) : <EOL> self . startsaving ( ) <EOL> def close_value ( self ) : <EOL> key = self . collectsavings ( ) <EOL> if key in self . values . keys ( ) : <EOL> self . write ( self . values [ key ] ) <EOL> else : <EOL> print '<STR_LIT>' , key <EOL> do_finalout = do_comment <EOL> do_setchapternewpage = do_comment <EOL> do_setfilename = do_comment <EOL> def do_settitle ( self , args ) : <EOL> self . startsaving ( ) <EOL> self . expand ( args ) <EOL> self . title = self . collectsavings ( ) <EOL> def do_parskip ( self , args ) : pass <EOL> def do_bye ( self , args ) : <EOL> self . endnode ( ) <EOL> self . done = <NUM_LIT:1> <EOL> def bgn_titlepage ( self , args ) : self . skip = self . skip + <NUM_LIT:1> <EOL> def end_titlepage ( self ) : self . skip = self . skip - <NUM_LIT:1> <EOL> def do_shorttitlepage ( self , args ) : pass <EOL> def do_center ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . expand ( args ) <EOL> self . write ( '<STR_LIT>' ) <EOL> do_title = do_center <EOL> do_subtitle = do_center <EOL> do_author = do_center <EOL> do_vskip = do_comment <EOL> do_vfill = do_comment <EOL> do_smallbook = do_comment <EOL> do_paragraphindent = do_comment <EOL> do_setchapternewpage = do_comment <EOL> do_headings = do_comment <EOL> do_footnotestyle = do_comment <EOL> do_evenheading = do_comment <EOL> do_evenfooting = do_comment <EOL> do_oddheading = do_comment <EOL> do_oddfooting = do_comment <EOL> do_everyheading = do_comment <EOL> do_everyfooting = do_comment <EOL> def do_node ( self , args ) : <EOL> self . endnode ( ) <EOL> self . nodelineno = <NUM_LIT:0> <EOL> parts = [ s . strip ( ) for s in args . split ( '<STR_LIT:U+002C>' ) ] <EOL> while len ( parts ) < <NUM_LIT:4> : parts . append ( '<STR_LIT>' ) <EOL> self . nodelinks = parts <EOL> [ name , next , prev , up ] = parts [ : <NUM_LIT:4> ] <EOL> file = self . dirname + '<STR_LIT:/>' + makefile ( name ) <EOL> if self . filenames . has_key ( file ) : <EOL> print '<STR_LIT>' , file <EOL> else : <EOL> if self . debugging : print '<STR_LIT:!>' * self . debugging , '<STR_LIT>' , file <EOL> self . filenames [ file ] = <NUM_LIT:1> <EOL> self . nodename = name <EOL> if self . cont and self . nodestack : <EOL> self . nodestack [ - <NUM_LIT:1> ] . cont = self . nodename <EOL> if not self . topname : self . topname = name <EOL> title = name <EOL> if self . title : title = title + '<STR_LIT>' + self . title <EOL> self . node = self . Node ( self . dirname , self . nodename , self . topname , <EOL> title , next , prev , up ) <EOL> self . htmlhelp . addnode ( self . nodename , next , prev , up , file ) <EOL> def link ( self , label , nodename ) : <EOL> if nodename : <EOL> if nodename . lower ( ) == '<STR_LIT>' : <EOL> addr = '<STR_LIT>' <EOL> else : <EOL> addr = makefile ( nodename ) <EOL> self . write ( label , '<STR_LIT>' , addr , '<STR_LIT>' , <EOL> label , '<STR_LIT>' , nodename , '<STR_LIT>' ) <EOL> def popstack ( self , type ) : <EOL> if ( self . node ) : <EOL> self . node . type = type <EOL> while self . nodestack : <EOL> if self . nodestack [ - <NUM_LIT:1> ] . type > type : <EOL> self . nodestack [ - <NUM_LIT:1> ] . finalize ( ) <EOL> self . nodestack [ - <NUM_LIT:1> ] . flush ( ) <EOL> del self . nodestack [ - <NUM_LIT:1> ] <EOL> elif self . nodestack [ - <NUM_LIT:1> ] . type == type : <EOL> if not self . nodestack [ - <NUM_LIT:1> ] . next : <EOL> self . nodestack [ - <NUM_LIT:1> ] . next = self . node . name <EOL> if not self . node . prev : <EOL> self . node . prev = self . nodestack [ - <NUM_LIT:1> ] . name <EOL> self . nodestack [ - <NUM_LIT:1> ] . finalize ( ) <EOL> self . nodestack [ - <NUM_LIT:1> ] . flush ( ) <EOL> del self . nodestack [ - <NUM_LIT:1> ] <EOL> else : <EOL> if type > <NUM_LIT:1> and not self . node . up : <EOL> self . node . up = self . nodestack [ - <NUM_LIT:1> ] . name <EOL> break <EOL> def do_chapter ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , <NUM_LIT:0> ) <EOL> self . popstack ( <NUM_LIT:1> ) <EOL> def do_unnumbered ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:1> ) <EOL> def do_appendix ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:1> ) <EOL> def do_top ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> def do_chapheading ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> def do_majorheading ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> def do_section ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:2> ) <EOL> def do_unnumberedsec ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:2> ) <EOL> def do_appendixsec ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:2> ) <EOL> do_appendixsection = do_appendixsec <EOL> def do_heading ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> def do_subsection ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , <NUM_LIT:2> ) <EOL> self . popstack ( <NUM_LIT:3> ) <EOL> def do_unnumberedsubsec ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:3> ) <EOL> def do_appendixsubsec ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:3> ) <EOL> def do_subheading ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> def do_subsubsection ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , <NUM_LIT:3> ) <EOL> self . popstack ( <NUM_LIT:4> ) <EOL> def do_unnumberedsubsubsec ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:4> ) <EOL> def do_appendixsubsubsec ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> self . popstack ( <NUM_LIT:4> ) <EOL> def do_subsubheading ( self , args ) : <EOL> self . heading ( '<STR_LIT>' , args , - <NUM_LIT:1> ) <EOL> def heading ( self , type , args , level ) : <EOL> if level >= <NUM_LIT:0> : <EOL> while len ( self . numbering ) <= level : <EOL> self . numbering . append ( <NUM_LIT:0> ) <EOL> del self . numbering [ level + <NUM_LIT:1> : ] <EOL> self . numbering [ level ] = self . numbering [ level ] + <NUM_LIT:1> <EOL> x = '<STR_LIT>' <EOL> for i in self . numbering : <EOL> x = x + repr ( i ) + '<STR_LIT:.>' <EOL> args = x + '<STR_LIT:U+0020>' + args <EOL> self . contents . append ( ( level , args , self . nodename ) ) <EOL> self . write ( '<STR_LIT:<>' , type , '<STR_LIT:>>' ) <EOL> self . expand ( args ) <EOL> self . write ( '<STR_LIT>' , type , '<STR_LIT>' ) <EOL> if self . debugging or self . print_headers : <EOL> print '<STR_LIT>' , args <EOL> def do_contents ( self , args ) : <EOL> self . listcontents ( '<STR_LIT>' , <NUM_LIT> ) <EOL> def do_shortcontents ( self , args ) : <EOL> pass <EOL> do_summarycontents = do_shortcontents <EOL> def listcontents ( self , title , maxlevel ) : <EOL> self . write ( '<STR_LIT>' , title , '<STR_LIT>' ) <EOL> prevlevels = [ <NUM_LIT:0> ] <EOL> for level , title , node in self . contents : <EOL> if level > maxlevel : <EOL> continue <EOL> if level > prevlevels [ - <NUM_LIT:1> ] : <EOL> self . write ( '<STR_LIT:U+0020>' * prevlevels [ - <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> prevlevels . append ( level ) <EOL> elif level < prevlevels [ - <NUM_LIT:1> ] : <EOL> while level < prevlevels [ - <NUM_LIT:1> ] : <EOL> del prevlevels [ - <NUM_LIT:1> ] <EOL> self . write ( '<STR_LIT:U+0020>' * prevlevels [ - <NUM_LIT:1> ] , <EOL> '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT:U+0020>' * level , '<STR_LIT>' , <EOL> makefile ( node ) , '<STR_LIT>' ) <EOL> self . expand ( title ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT>' * len ( prevlevels ) ) <EOL> def do_page ( self , args ) : pass <EOL> def do_need ( self , args ) : pass <EOL> def bgn_group ( self , args ) : pass <EOL> def end_group ( self ) : pass <EOL> def do_sp ( self , args ) : <EOL> if self . nofill : <EOL> self . write ( '<STR_LIT:\n>' ) <EOL> else : <EOL> self . write ( '<STR_LIT>' ) <EOL> def do_hline ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> def bgn_deffn ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_deffnx ( args ) <EOL> def end_deffn ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> def do_deffnx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:2> ) <EOL> [ category , name ] , rest = words [ : <NUM_LIT:2> ] , words [ <NUM_LIT:2> : ] <EOL> self . expand ( '<STR_LIT>' % name ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + makevar ( word ) ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , name ) <EOL> def bgn_defun ( self , args ) : self . bgn_deffn ( '<STR_LIT>' + args ) <EOL> end_defun = end_deffn <EOL> def do_defunx ( self , args ) : self . do_deffnx ( '<STR_LIT>' + args ) <EOL> def bgn_defmac ( self , args ) : self . bgn_deffn ( '<STR_LIT>' + args ) <EOL> end_defmac = end_deffn <EOL> def do_defmacx ( self , args ) : self . do_deffnx ( '<STR_LIT>' + args ) <EOL> def bgn_defspec ( self , args ) : self . bgn_deffn ( '<STR_LIT>' + args ) <EOL> end_defspec = end_deffn <EOL> def do_defspecx ( self , args ) : self . do_deffnx ( '<STR_LIT>' + args ) <EOL> def bgn_defvr ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_defvrx ( args ) <EOL> end_defvr = end_deffn <EOL> def do_defvrx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:2> ) <EOL> [ category , name ] , rest = words [ : <NUM_LIT:2> ] , words [ <NUM_LIT:2> : ] <EOL> self . expand ( '<STR_LIT>' % name ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + word ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , name ) <EOL> def bgn_defvar ( self , args ) : self . bgn_defvr ( '<STR_LIT>' + args ) <EOL> end_defvar = end_defvr <EOL> def do_defvarx ( self , args ) : self . do_defvrx ( '<STR_LIT>' + args ) <EOL> def bgn_defopt ( self , args ) : self . bgn_defvr ( '<STR_LIT>' + args ) <EOL> end_defopt = end_defvr <EOL> def do_defoptx ( self , args ) : self . do_defvrx ( '<STR_LIT>' + args ) <EOL> def bgn_deftypefn ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_deftypefnx ( args ) <EOL> end_deftypefn = end_deffn <EOL> def do_deftypefnx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:3> ) <EOL> [ category , datatype , name ] , rest = words [ : <NUM_LIT:3> ] , words [ <NUM_LIT:3> : ] <EOL> self . expand ( '<STR_LIT>' % ( datatype , name ) ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + makevar ( word ) ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , name ) <EOL> def bgn_deftypefun ( self , args ) : self . bgn_deftypefn ( '<STR_LIT>' + args ) <EOL> end_deftypefun = end_deftypefn <EOL> def do_deftypefunx ( self , args ) : self . do_deftypefnx ( '<STR_LIT>' + args ) <EOL> def bgn_deftypevr ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_deftypevrx ( args ) <EOL> end_deftypevr = end_deftypefn <EOL> def do_deftypevrx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:3> ) <EOL> [ category , datatype , name ] , rest = words [ : <NUM_LIT:3> ] , words [ <NUM_LIT:3> : ] <EOL> self . expand ( '<STR_LIT>' % ( datatype , name ) ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + word ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , name ) <EOL> def bgn_deftypevar ( self , args ) : <EOL> self . bgn_deftypevr ( '<STR_LIT>' + args ) <EOL> end_deftypevar = end_deftypevr <EOL> def do_deftypevarx ( self , args ) : <EOL> self . do_deftypevrx ( '<STR_LIT>' + args ) <EOL> def bgn_defcv ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_defcvx ( args ) <EOL> end_defcv = end_deftypevr <EOL> def do_defcvx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:3> ) <EOL> [ category , classname , name ] , rest = words [ : <NUM_LIT:3> ] , words [ <NUM_LIT:3> : ] <EOL> self . expand ( '<STR_LIT>' % name ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + word ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , '<STR_LIT>' % ( name , classname ) ) <EOL> def bgn_defivar ( self , args ) : <EOL> self . bgn_defcv ( '<STR_LIT>' + args ) <EOL> end_defivar = end_defcv <EOL> def do_defivarx ( self , args ) : <EOL> self . do_defcvx ( '<STR_LIT>' + args ) <EOL> def bgn_defop ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_defopx ( args ) <EOL> end_defop = end_defcv <EOL> def do_defopx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:3> ) <EOL> [ category , classname , name ] , rest = words [ : <NUM_LIT:3> ] , words [ <NUM_LIT:3> : ] <EOL> self . expand ( '<STR_LIT>' % name ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + makevar ( word ) ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , '<STR_LIT>' % ( name , classname ) ) <EOL> def bgn_defmethod ( self , args ) : <EOL> self . bgn_defop ( '<STR_LIT>' + args ) <EOL> end_defmethod = end_defop <EOL> def do_defmethodx ( self , args ) : <EOL> self . do_defopx ( '<STR_LIT>' + args ) <EOL> def bgn_deftp ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . do_deftpx ( args ) <EOL> end_deftp = end_defcv <EOL> def do_deftpx ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> words = splitwords ( args , <NUM_LIT:2> ) <EOL> [ category , name ] , rest = words [ : <NUM_LIT:2> ] , words [ <NUM_LIT:2> : ] <EOL> self . expand ( '<STR_LIT>' % name ) <EOL> for word in rest : self . expand ( '<STR_LIT:U+0020>' + word ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . index ( '<STR_LIT>' , name ) <EOL> def bgn_enumerate ( self , args ) : <EOL> if not args : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . stackinfo [ len ( self . stack ) ] = '<STR_LIT>' <EOL> else : <EOL> self . itemnumber = args <EOL> self . write ( '<STR_LIT>' ) <EOL> self . stackinfo [ len ( self . stack ) ] = '<STR_LIT>' <EOL> def end_enumerate ( self ) : <EOL> self . itemnumber = None <EOL> self . write ( self . stackinfo [ len ( self . stack ) + <NUM_LIT:1> ] ) <EOL> del self . stackinfo [ len ( self . stack ) + <NUM_LIT:1> ] <EOL> def bgn_itemize ( self , args ) : <EOL> self . itemarg = args <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_itemize ( self ) : <EOL> self . itemarg = None <EOL> self . write ( '<STR_LIT>' ) <EOL> def bgn_table ( self , args ) : <EOL> self . itemarg = args <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_table ( self ) : <EOL> self . itemarg = None <EOL> self . write ( '<STR_LIT>' ) <EOL> def bgn_ftable ( self , args ) : <EOL> self . itemindex = '<STR_LIT>' <EOL> self . bgn_table ( args ) <EOL> def end_ftable ( self ) : <EOL> self . itemindex = None <EOL> self . end_table ( ) <EOL> def bgn_vtable ( self , args ) : <EOL> self . itemindex = '<STR_LIT>' <EOL> self . bgn_table ( args ) <EOL> def end_vtable ( self ) : <EOL> self . itemindex = None <EOL> self . end_table ( ) <EOL> def do_item ( self , args ) : <EOL> if self . itemindex : self . index ( self . itemindex , args ) <EOL> if self . itemarg : <EOL> if self . itemarg [ <NUM_LIT:0> ] == '<STR_LIT:@>' and self . itemarg [ <NUM_LIT:1> ] and self . itemarg [ <NUM_LIT:1> ] in string . ascii_letters : <EOL> args = self . itemarg + '<STR_LIT:{>' + args + '<STR_LIT:}>' <EOL> else : <EOL> args = self . itemarg + '<STR_LIT:U+0020>' + args <EOL> if self . itemnumber < > None : <EOL> args = self . itemnumber + '<STR_LIT>' + args <EOL> self . itemnumber = increment ( self . itemnumber ) <EOL> if self . stack and self . stack [ - <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . expand ( args ) <EOL> self . write ( '<STR_LIT>' ) <EOL> elif self . stack and self . stack [ - <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . expand ( args ) <EOL> self . write ( '<STR_LIT>' ) <EOL> else : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . expand ( args ) <EOL> self . write ( '<STR_LIT:U+0020>' ) <EOL> do_itemx = do_item <EOL> def bgn_multitable ( self , args ) : <EOL> self . itemarg = None <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_multitable ( self ) : <EOL> self . itemarg = None <EOL> self . write ( '<STR_LIT>' ) <EOL> def handle_columnfractions ( self ) : <EOL> self . itemarg = None <EOL> def handle_tab ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> def bgn_quotation ( self , args ) : self . write ( '<STR_LIT>' ) <EOL> def end_quotation ( self ) : self . write ( '<STR_LIT>' ) <EOL> def bgn_example ( self , args ) : <EOL> self . nofill = self . nofill + <NUM_LIT:1> <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_example ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . nofill = self . nofill - <NUM_LIT:1> <EOL> bgn_lisp = bgn_example <EOL> end_lisp = end_example <EOL> bgn_smallexample = bgn_example <EOL> end_smallexample = end_example <EOL> bgn_smalllisp = bgn_lisp <EOL> end_smalllisp = end_lisp <EOL> bgn_display = bgn_example <EOL> end_display = end_example <EOL> bgn_format = bgn_display <EOL> end_format = end_display <EOL> def do_exdent ( self , args ) : self . expand ( args + '<STR_LIT:\n>' ) <EOL> def bgn_flushleft ( self , args ) : <EOL> self . nofill = self . nofill + <NUM_LIT:1> <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_flushleft ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . nofill = self . nofill - <NUM_LIT:1> <EOL> def bgn_flushright ( self , args ) : <EOL> self . nofill = self . nofill + <NUM_LIT:1> <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_flushright ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . nofill = self . nofill - <NUM_LIT:1> <EOL> def bgn_menu ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT>' ) <EOL> self . htmlhelp . beginmenu ( ) <EOL> def end_menu ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . htmlhelp . endmenu ( ) <EOL> def bgn_cartouche ( self , args ) : pass <EOL> def end_cartouche ( self ) : pass <EOL> def resetindex ( self ) : <EOL> self . noncodeindices = [ '<STR_LIT>' ] <EOL> self . indextitle = { } <EOL> self . indextitle [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . indextitle [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . indextitle [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . indextitle [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . indextitle [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . indextitle [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . whichindex = { } <EOL> for name in self . indextitle . keys ( ) : <EOL> self . whichindex [ name ] = [ ] <EOL> def user_index ( self , name , args ) : <EOL> if self . whichindex . has_key ( name ) : <EOL> self . index ( name , args ) <EOL> else : <EOL> print '<STR_LIT>' , repr ( name ) <EOL> def do_cindex ( self , args ) : self . index ( '<STR_LIT>' , args ) <EOL> def do_findex ( self , args ) : self . index ( '<STR_LIT>' , args ) <EOL> def do_kindex ( self , args ) : self . index ( '<STR_LIT>' , args ) <EOL> def do_pindex ( self , args ) : self . index ( '<STR_LIT>' , args ) <EOL> def do_tindex ( self , args ) : self . index ( '<STR_LIT>' , args ) <EOL> def do_vindex ( self , args ) : self . index ( '<STR_LIT>' , args ) <EOL> def index ( self , name , args ) : <EOL> self . whichindex [ name ] . append ( ( args , self . nodename ) ) <EOL> self . htmlhelp . index ( args , self . nodename ) <EOL> def do_synindex ( self , args ) : <EOL> words = args . split ( ) <EOL> if len ( words ) < > <NUM_LIT:2> : <EOL> print '<STR_LIT>' , args <EOL> return <EOL> [ old , new ] = words <EOL> if not self . whichindex . has_key ( old ) or not self . whichindex . has_key ( new ) : <EOL> print '<STR_LIT>' , args <EOL> return <EOL> if old < > new and self . whichindex [ old ] is not self . whichindex [ new ] : <EOL> inew = self . whichindex [ new ] <EOL> inew [ len ( inew ) : ] = self . whichindex [ old ] <EOL> self . whichindex [ old ] = inew <EOL> do_syncodeindex = do_synindex <EOL> def do_printindex ( self , args ) : <EOL> words = args . split ( ) <EOL> for name in words : <EOL> if self . whichindex . has_key ( name ) : <EOL> self . prindex ( name ) <EOL> else : <EOL> print '<STR_LIT>' , repr ( name ) <EOL> def prindex ( self , name ) : <EOL> iscodeindex = ( name not in self . noncodeindices ) <EOL> index = self . whichindex [ name ] <EOL> if not index : return <EOL> if self . debugging : <EOL> print '<STR_LIT:!>' * self . debugging , '<STR_LIT>' , self . indextitle [ name ] , '<STR_LIT:index>' <EOL> index1 = [ ] <EOL> junkprog = re . compile ( '<STR_LIT>' ) <EOL> for key , node in index : <EOL> sortkey = key . lower ( ) <EOL> oldsortkey = sortkey <EOL> while <NUM_LIT:1> : <EOL> mo = junkprog . match ( sortkey ) <EOL> if not mo : <EOL> break <EOL> i = mo . end ( ) <EOL> sortkey = sortkey [ i : ] <EOL> index1 . append ( ( sortkey , key , node ) ) <EOL> del index [ : ] <EOL> index1 . sort ( ) <EOL> self . write ( '<STR_LIT>' ) <EOL> prevkey = prevnode = None <EOL> for sortkey , key , node in index1 : <EOL> if ( key , node ) == ( prevkey , prevnode ) : <EOL> continue <EOL> if self . debugging > <NUM_LIT:1> : print '<STR_LIT:!>' * self . debugging , key , '<STR_LIT::>' , node <EOL> self . write ( '<STR_LIT>' ) <EOL> if iscodeindex : key = '<STR_LIT>' + key + '<STR_LIT:}>' <EOL> if key != prevkey : <EOL> self . expand ( key ) <EOL> self . write ( '<STR_LIT>' % ( makefile ( node ) , node ) ) <EOL> prevkey , prevnode = key , node <EOL> self . write ( '<STR_LIT>' ) <EOL> def report ( self ) : <EOL> if self . unknown : <EOL> print '<STR_LIT>' <EOL> cmds = self . unknown . keys ( ) <EOL> cmds . sort ( ) <EOL> for cmd in cmds : <EOL> print cmd . ljust ( <NUM_LIT:20> ) , self . unknown [ cmd ] <EOL> class TexinfoParserHTML3 ( TexinfoParser ) : <EOL> COPYRIGHT_SYMBOL = "<STR_LIT>" <EOL> FN_ID_PATTERN = "<STR_LIT>" <EOL> FN_SOURCE_PATTERN = '<STR_LIT>' '<STR_LIT>' + FN_ID_PATTERN + '<STR_LIT>' <EOL> FN_TARGET_PATTERN = '<STR_LIT>' '<STR_LIT>' + FN_ID_PATTERN + '<STR_LIT>' <EOL> FN_HEADER = '<STR_LIT>' '<STR_LIT>' <EOL> Node = HTML3Node <EOL> def bgn_quotation ( self , args ) : self . write ( '<STR_LIT>' ) <EOL> def end_quotation ( self ) : self . write ( '<STR_LIT>' ) <EOL> def bgn_example ( self , args ) : <EOL> self . nofill = self . nofill + <NUM_LIT:1> <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_example ( self ) : <EOL> self . write ( "<STR_LIT>" ) <EOL> self . nofill = self . nofill - <NUM_LIT:1> <EOL> def bgn_flushleft ( self , args ) : <EOL> self . nofill = self . nofill + <NUM_LIT:1> <EOL> self . write ( '<STR_LIT>' ) <EOL> def bgn_flushright ( self , args ) : <EOL> self . nofill = self . nofill + <NUM_LIT:1> <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_flushright ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . nofill = self . nofill - <NUM_LIT:1> <EOL> def bgn_menu ( self , args ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT>' ) <EOL> def end_menu ( self ) : <EOL> self . write ( '<STR_LIT>' ) <EOL> class HTMLHelp : <EOL> """<STR_LIT>""" <EOL> codeprog = re . compile ( '<STR_LIT>' ) <EOL> def __init__ ( self , helpbase , dirname ) : <EOL> self . helpbase = helpbase <EOL> self . dirname = dirname <EOL> self . projectfile = None <EOL> self . contentfile = None <EOL> self . indexfile = None <EOL> self . nodelist = [ ] <EOL> self . nodenames = { } <EOL> self . nodeindex = { } <EOL> self . filenames = { } <EOL> self . indexlist = [ ] <EOL> self . current = '<STR_LIT>' <EOL> self . menudict = { } <EOL> self . dumped = { } <EOL> def addnode ( self , name , next , prev , up , filename ) : <EOL> node = ( name , next , prev , up , filename ) <EOL> self . filenames [ filename ] = filename <EOL> self . nodeindex [ name ] = len ( self . nodelist ) <EOL> self . nodelist . append ( node ) <EOL> self . current = name <EOL> self . menudict [ self . current ] = [ ] <EOL> def menuitem ( self , nodename ) : <EOL> menu = self . menudict [ self . current ] <EOL> menu . append ( nodename ) <EOL> def addimage ( self , imagename ) : <EOL> self . filenames [ imagename ] = imagename <EOL> def index ( self , args , nodename ) : <EOL> self . indexlist . append ( ( args , nodename ) ) <EOL> def beginmenu ( self ) : <EOL> pass <EOL> def endmenu ( self ) : <EOL> pass <EOL> def finalize ( self ) : <EOL> if not self . helpbase : <EOL> return <EOL> resultfile = self . helpbase + '<STR_LIT>' <EOL> projectfile = self . helpbase + '<STR_LIT>' <EOL> contentfile = self . helpbase + '<STR_LIT>' <EOL> indexfile = self . helpbase + '<STR_LIT>' <EOL> title = self . helpbase <EOL> ( topname , topnext , topprev , topup , topfile ) = self . nodelist [ <NUM_LIT:0> ] <EOL> defaulttopic = topfile <EOL> try : <EOL> fp = open ( projectfile , '<STR_LIT:w>' ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' + resultfile + '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' + contentfile + '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' + defaulttopic + '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' + indexfile + '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' + title + '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , ( '<STR_LIT>' + contentfile + '<STR_LIT>' + indexfile <EOL> + '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> self . dumpfiles ( fp ) <EOL> fp . close ( ) <EOL> except IOError , msg : <EOL> print projectfile , '<STR_LIT::>' , msg <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> try : <EOL> fp = open ( contentfile , '<STR_LIT:w>' ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> self . dumpnodes ( fp ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> fp . close ( ) <EOL> except IOError , msg : <EOL> print contentfile , '<STR_LIT::>' , msg <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> try : <EOL> fp = open ( indexfile , '<STR_LIT:w>' ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> self . dumpindex ( fp ) <EOL> print >> fp , '<STR_LIT>' <EOL> print >> fp , '<STR_LIT>' <EOL> fp . close ( ) <EOL> except IOError , msg : <EOL> print indexfile , '<STR_LIT::>' , msg <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def dumpfiles ( self , outfile = sys . stdout ) : <EOL> filelist = self . filenames . values ( ) <EOL> filelist . sort ( ) <EOL> for filename in filelist : <EOL> print >> outfile , filename <EOL> def dumpnodes ( self , outfile = sys . stdout ) : <EOL> self . dumped = { } <EOL> if self . nodelist : <EOL> nodename , dummy , dummy , dummy , dummy = self . nodelist [ <NUM_LIT:0> ] <EOL> self . topnode = nodename <EOL> print >> outfile , '<STR_LIT>' <EOL> for node in self . nodelist : <EOL> self . dumpnode ( node , <NUM_LIT:0> , outfile ) <EOL> print >> outfile , '<STR_LIT>' <EOL> def dumpnode ( self , node , indent = <NUM_LIT:0> , outfile = sys . stdout ) : <EOL> if node : <EOL> ( nodename , next , prev , up , filename ) = node <EOL> self . current = nodename <EOL> if self . dumped . has_key ( nodename ) : <EOL> return <EOL> self . dumped [ nodename ] = <NUM_LIT:1> <EOL> print >> outfile , '<STR_LIT:U+0020>' * indent , <EOL> print >> outfile , '<STR_LIT>' , <EOL> print >> outfile , '<STR_LIT>' + nodename + '<STR_LIT>' , <EOL> print >> outfile , '<STR_LIT>' + filename + '<STR_LIT>' , <EOL> print >> outfile , '<STR_LIT>' <EOL> try : <EOL> menu = self . menudict [ nodename ] <EOL> self . dumpmenu ( menu , indent + <NUM_LIT:2> , outfile ) <EOL> except KeyError : <EOL> pass <EOL> def dumpmenu ( self , menu , indent = <NUM_LIT:0> , outfile = sys . stdout ) : <EOL> if menu : <EOL> currentnode = self . current <EOL> if currentnode != self . topnode : <EOL> print >> outfile , '<STR_LIT:U+0020>' * indent + '<STR_LIT>' <EOL> indent += <NUM_LIT:2> <EOL> for item in menu : <EOL> menunode = self . getnode ( item ) <EOL> self . dumpnode ( menunode , indent , outfile ) <EOL> if currentnode != self . topnode : <EOL> print >> outfile , '<STR_LIT:U+0020>' * indent + '<STR_LIT>' <EOL> indent -= <NUM_LIT:2> <EOL> def getnode ( self , nodename ) : <EOL> try : <EOL> index = self . nodeindex [ nodename ] <EOL> return self . nodelist [ index ] <EOL> except KeyError : <EOL> return None <EOL> except IndexError : <EOL> return None <EOL> def dumpindex ( self , outfile = sys . stdout ) : <EOL> print >> outfile , '<STR_LIT>' <EOL> for ( key , location ) in self . indexlist : <EOL> key = self . codeexpand ( key ) <EOL> location = makefile ( location ) <EOL> location = self . dirname + '<STR_LIT:/>' + location <EOL> print >> outfile , '<STR_LIT>' , <EOL> print >> outfile , '<STR_LIT>' + key + '<STR_LIT>' , <EOL> print >> outfile , '<STR_LIT>' + location + '<STR_LIT>' , <EOL> print >> outfile , '<STR_LIT>' <EOL> print >> outfile , '<STR_LIT>' <EOL> def codeexpand ( self , line ) : <EOL> co = self . codeprog . match ( line ) <EOL> if not co : <EOL> return line <EOL> bgn , end = co . span ( <NUM_LIT:0> ) <EOL> a , b = co . span ( <NUM_LIT:1> ) <EOL> line = line [ : bgn ] + line [ a : b ] + line [ end : ] <EOL> return line <EOL> def makevar ( str ) : <EOL> return '<STR_LIT>' + str + '<STR_LIT:}>' <EOL> def splitwords ( str , minlength ) : <EOL> words = [ ] <EOL> i = <NUM_LIT:0> <EOL> n = len ( str ) <EOL> while i < n : <EOL> while i < n and str [ i ] in '<STR_LIT>' : i = i + <NUM_LIT:1> <EOL> if i >= n : break <EOL> start = i <EOL> i = findwordend ( str , i , n ) <EOL> words . append ( str [ start : i ] ) <EOL> while len ( words ) < minlength : words . append ( '<STR_LIT>' ) <EOL> return words <EOL> fwprog = re . compile ( '<STR_LIT>' ) <EOL> def findwordend ( str , i , n ) : <EOL> level = <NUM_LIT:0> <EOL> while i < n : <EOL> mo = fwprog . search ( str , i ) <EOL> if not mo : <EOL> break <EOL> i = mo . start ( ) <EOL> c = str [ i ] ; i = i + <NUM_LIT:1> <EOL> if c == '<STR_LIT:@>' : i = i + <NUM_LIT:1> <EOL> elif c == '<STR_LIT:{>' : level = level + <NUM_LIT:1> <EOL> elif c == '<STR_LIT:}>' : level = level - <NUM_LIT:1> <EOL> elif c == '<STR_LIT:U+0020>' and level <= <NUM_LIT:0> : return i - <NUM_LIT:1> <EOL> return n <EOL> def makefile ( nodename ) : <EOL> nodename = nodename . strip ( ) <EOL> return fixfunnychars ( nodename ) + '<STR_LIT>' <EOL> goodchars = string . ascii_letters + string . digits + '<STR_LIT>' <EOL> def fixfunnychars ( addr ) : <EOL> i = <NUM_LIT:0> <EOL> while i < len ( addr ) : <EOL> c = addr [ i ] <EOL> if c not in goodchars : <EOL> c = '<STR_LIT:->' <EOL> addr = addr [ : i ] + c + addr [ i + <NUM_LIT:1> : ] <EOL> i = i + len ( c ) <EOL> return addr <EOL> def increment ( s ) : <EOL> if not s : <EOL> return '<STR_LIT:1>' <EOL> for sequence in string . digits , string . lowercase , string . uppercase : <EOL> lastc = s [ - <NUM_LIT:1> ] <EOL> if lastc in sequence : <EOL> i = sequence . index ( lastc ) + <NUM_LIT:1> <EOL> if i >= len ( sequence ) : <EOL> if len ( s ) == <NUM_LIT:1> : <EOL> s = sequence [ <NUM_LIT:0> ] * <NUM_LIT:2> <EOL> if s == '<STR_LIT>' : <EOL> s = '<STR_LIT>' <EOL> else : <EOL> s = increment ( s [ : - <NUM_LIT:1> ] ) + sequence [ <NUM_LIT:0> ] <EOL> else : <EOL> s = s [ : - <NUM_LIT:1> ] + sequence [ i ] <EOL> return s <EOL> return s <EOL> def test ( ) : <EOL> import sys <EOL> debugging = <NUM_LIT:0> <EOL> print_headers = <NUM_LIT:0> <EOL> cont = <NUM_LIT:0> <EOL> html3 = <NUM_LIT:0> <EOL> htmlhelp = '<STR_LIT>' <EOL> while sys . argv [ <NUM_LIT:1> ] == [ '<STR_LIT>' ] : <EOL> debugging = debugging + <NUM_LIT:1> <EOL> del sys . argv [ <NUM_LIT:1> ] <EOL> if sys . argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> print_headers = <NUM_LIT:1> <EOL> del sys . argv [ <NUM_LIT:1> ] <EOL> if sys . argv [ <NUM_LIT:1> ] == '<STR_LIT:-c>' : <EOL> cont = <NUM_LIT:1> <EOL> del sys . argv [ <NUM_LIT:1> ] <EOL> if sys . argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> html3 = <NUM_LIT:1> <EOL> del sys . argv [ <NUM_LIT:1> ] <EOL> if sys . argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> helpbase = sys . argv [ <NUM_LIT:2> ] <EOL> del sys . argv [ <NUM_LIT:1> : <NUM_LIT:3> ] <EOL> if len ( sys . argv ) < > <NUM_LIT:3> : <EOL> print '<STR_LIT>' , '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if html3 : <EOL> parser = TexinfoParserHTML3 ( ) <EOL> else : <EOL> parser = TexinfoParser ( ) <EOL> parser . cont = cont <EOL> parser . debugging = debugging <EOL> parser . print_headers = print_headers <EOL> file = sys . argv [ <NUM_LIT:1> ] <EOL> dirname = sys . argv [ <NUM_LIT:2> ] <EOL> parser . setdirname ( dirname ) <EOL> parser . setincludedir ( os . path . dirname ( file ) ) <EOL> htmlhelp = HTMLHelp ( helpbase , dirname ) <EOL> parser . sethtmlhelp ( htmlhelp ) <EOL> try : <EOL> fp = open ( file , '<STR_LIT:r>' ) <EOL> except IOError , msg : <EOL> print file , '<STR_LIT::>' , msg <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> parser . parse ( fp ) <EOL> fp . close ( ) <EOL> parser . report ( ) <EOL> htmlhelp . finalize ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test ( ) </s>
