<s> """<STR_LIT>""" <EOL> import os , cgi <EOL> from xml . dom import minidom as dom <EOL> from twisted . lore import latex <EOL> class DocbookSpitter ( latex . BaseLatexSpitter ) : <EOL> currentLevel = <NUM_LIT:1> <EOL> def writeNodeData ( self , node ) : <EOL> self . writer ( node . data ) <EOL> def visitNode_body ( self , node ) : <EOL> self . visitNodeDefault ( node ) <EOL> self . writer ( '<STR_LIT>' * self . currentLevel ) <EOL> def visitNodeHeader ( self , node ) : <EOL> level = int ( node . tagName [ <NUM_LIT:1> ] ) <EOL> difference , self . currentLevel = level - self . currentLevel , level <EOL> self . writer ( '<STR_LIT>' * difference + '<STR_LIT>' * - difference ) <EOL> if difference <= <NUM_LIT:0> : <EOL> self . writer ( '<STR_LIT>' ) <EOL> self . writer ( '<STR_LIT>' ) <EOL> self . visitNodeDefault ( node ) <EOL> def visitNode_a_listing ( self , node ) : <EOL> fileName = os . path . join ( self . currDir , node . getAttribute ( '<STR_LIT>' ) ) <EOL> self . writer ( '<STR_LIT>' ) <EOL> self . writer ( cgi . escape ( open ( fileName ) . read ( ) ) ) <EOL> self . writer ( '<STR_LIT>' ) <EOL> def visitNode_a_href ( self , node ) : <EOL> self . visitNodeDefault ( node ) <EOL> def visitNode_a_name ( self , node ) : <EOL> self . visitNodeDefault ( node ) <EOL> def visitNode_li ( self , node ) : <EOL> for child in node . childNodes : <EOL> if getattr ( child , '<STR_LIT>' , None ) != '<STR_LIT:p>' : <EOL> new = dom . Element ( '<STR_LIT:p>' ) <EOL> new . childNodes = [ child ] <EOL> node . replaceChild ( new , child ) <EOL> self . visitNodeDefault ( node ) <EOL> visitNode_h2 = visitNode_h3 = visitNode_h4 = visitNodeHeader <EOL> end_h2 = end_h3 = end_h4 = '<STR_LIT>' <EOL> start_title , end_title = '<STR_LIT>' , '<STR_LIT>' <EOL> start_p , end_p = '<STR_LIT>' , '<STR_LIT>' <EOL> start_strong , end_strong = start_em , end_em = '<STR_LIT>' , '<STR_LIT>' <EOL> start_span_footnote , end_span_footnote = '<STR_LIT>' , '<STR_LIT>' <EOL> start_q = end_q = '<STR_LIT:">' <EOL> start_pre , end_pre = '<STR_LIT>' , '<STR_LIT>' <EOL> start_div_note , end_div_note = '<STR_LIT>' , '<STR_LIT>' <EOL> start_li , end_li = '<STR_LIT>' , '<STR_LIT>' <EOL> start_ul , end_ul = '<STR_LIT>' , '<STR_LIT>' <EOL> start_ol , end_ol = '<STR_LIT>' , '<STR_LIT>' <EOL> start_dl , end_dl = '<STR_LIT>' , '<STR_LIT>' <EOL> start_dt , end_dt = '<STR_LIT>' , '<STR_LIT>' <EOL> start_dd , end_dd = '<STR_LIT>' , '<STR_LIT>' </s>
