# EG # fd = sys.stdout fd = open(ofile, "w") # DEAD # fd = spin_py.SPIN_write_buffer( fd, 10240, 102400 ) lo = 10240 hi = 102400 pr = spin_py.SPIN_tree_print(fd, lo, hi) # need the DTD to write at the top of the file pr.write(EH.dtd_line + "\n") pr.print_tree(EH.tree) # no need to call flush2() manually # pr.flush2() # fd.flush2() t4 = time() EH.tree = None EH.top = None EH = None # all done calculate the times def fmt(str, t1, t2): dt = t2 - t1 s = " %s - %4.2f \n" % (str, dt) stderr.write(s) print "# How long did it take?" fmt("setup", t1, t2) # usually 0.00 fmt("load", t2, t3)
children auto come from the same dtd_pool NB an unlimited number of variations are not supported. eg append new instance is inst1.data.append( inst2 ) """ t2 = time() # first set the DTD related settings EH.dtd_line = "" EH.setup_HTML() # The TOP element has to be created manually # WAS # ei_HTML = EH.dtd_info.get_elem_info("HTML") # WAS # HTML = spin_py.SPIN_elem_obj( ei_HTML, [], [] ) HTML = EH.dtd_info.new_elem_inst("HTML") EH.tree = HTML # It can then create children in quicker steps # This uses an ELEM_OBJ to find the ELEM_INFO_POOL (dtd) # then lookup "HEAD" to get its elem_info (auto add as ... default type) # then create an ELEM_OBJ (with atts and body defaulting to empty lists) # then APPEND that to the first element # and return to paste children or set attributes # HEAD = HTML.add_elem("HEAD") TITLE = HEAD.add_elem("TITLE") TITLE.add_text("This is the documents title") LINK = HEAD.add_elem("LINK") LINK.add_attr("rel", "stylesheet")
# TODO: generate OUTPUT HTML from INPUT SGML - wont use EH as destination! # In particular both input and output need a "dtd", "elem_info_pool", etc EH = SP_EH( "SPIN_Python_gen" ) # EH.dtd_line = "" # done by setup_HTML for previously blank dtd_line EH.setup_HTML() # The TOP "HTML" element has to be created manually # # EH.dtd_info is a pool of ei-elem-info's # build a (unique) el-element from that (reused) name # set that as the output TOP (EH does everything, and a few extra things) # ei_HTML = EH.dtd_info.get_elem_info("HTML") el_HTML = spin_py.SPIN_elem_obj( ei_HTML, [], [] ) EH.tree = el_HTML t2 = time() # pick a file WWW_127 = 0 # not local if len(argv) > 1: if argv[1] == "WWW_127": WWW_127 = 1 # local if WWW_127: ofile="HTDOCS/index.html" else: ofile="index.htm"
# It is setup as a placebo that doesnt receive HTML events, but functions # TODO: generate OUTPUT HTML from INPUT SGML - wont use EH as destination! # In particular both input and output need a "dtd", "elem_info_pool", etc EH = SP_EH("SPIN_Python_gen") # EH.dtd_line = "" # done by setup_HTML for previously blank dtd_line EH.setup_WML() # The TOP "WML" element has to be created manually # WHY ?? # surely that can be donw by EH.setup_TOP # maybe with later overrides for lang ? ei_WML = EH.dtd_info.get_elem_info("WML") el_WML = spin_py.SPIN_elem_obj(ei_WML, [], []) EH.tree = el_WML t2 = time() # pick a file WWW_127 = 0 # not local if len(argv) > 1: if argv[1] == "WWW_127": WWW_127 = 1 # local if WWW_127: ofile = "HTDOCS/index.html" else: ofile = "w.wml" el_CARD = el_WML.add_elem("CARD")