path.insert(1, p0+"/../lib_base/" ) # used # put the loader side of the jigsaw pieces together ... # see also the /etc/sgml paths in base/spin_eh.py # from spin_eh import spin_py, SP_EH # # spin_py.GDB_INVOKE(); # create a new Event Handler # This app doesnt use it to handle events though! # 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_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()
file = "test1.sg" ofile = "test1.sgm" if len(argv) == 2: file = argv[1] else: if len(argv) == 3: file = argv[1] ofile = argv[2] # SP_EH is a generic base class of SPIN_LDOC # it is the SPIN event handler # it activates spin_py, and gets called back # it contains the /etc/sgml/catalog parameters # so if you don't have /usr/src/sp/pubtext/html.soc - edit that back in EH = SP_EH("spin2") # run SP over it # the result is placed by DocumentEnd # into EH.tree files = [file] t2 = time() ret = EH.Run(files) ## the MAIN part of the program ## t3 = time() print "ret val ", ret print "--" # SP has now disappeared, and the document is loaded as EH.tree # dump/print the EH.tree to stdout
file = "test1.sg" ofile = "test1.sgm" if len(argv) == 2: file = argv[1] else: if len(argv) == 3: file = argv[1] ofile = argv[2] # SP_EH is a generic base class of SPIN_LDOC # it is the SPIN event handler # it activates spin_py, and gets called back # it contains the /etc/sgml/catalog parameters # so if you don't have /usr/src/sp/pubtext/html.soc - edit that back in EH = SP_EH("gen1") # run SP over it # the result is placed by DocumentEnd # into EH.tree if 0: files = [file] t2 = time() ret = EH.Run(files) ## the MAIN part of the program ## t3 = time() print "ret val ", ret print "--" # SP has now disappeared, and the document is loaded as EH.tree # - or instead - build the tree manually