Exemple #1
0
 def __init__(self, name="Generator"):
     SP_EH.__init__(self, name)
     self.generator = name
     # first set the DTD related settings
     self.setup_HTML()
     self.dtd_line = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
     # The TREE TOP element has to be created manually
     HTML_info = self.dtd_info.get_elem_info("HTML")
     HTML = spin_py.SPIN_elem_obj(HTML_info, [], [])
     self.tree = HTML
Exemple #2
0
    def __init__(self, name):
        # parent constructor
        SP_EH.__init__(self, name)
        self.debug3 = 0
        # elemen_info's used by TOC_TREE
        # pre-registered elem_info's
        self.ul = self.dtd_info.set_elem_block('UL')
        self.li = self.dtd_info.set_elem_block('LI')
        self.div = self.dtd_info.set_elem_block('DIV')
        self.body = self.dtd_info.set_elem_block('BODY')
        self.title = self.dtd_info.set_elem_defaults('TITLE')
        self.br = self.dtd_info.set_elem_empty('BR')
        self.hr = self.dtd_info.set_elem_empty('HR')
        self.h1 = self.dtd_info.set_elem_block('H1')
        self.h2 = self.dtd_info.set_elem_block('H2')
        self.h3 = self.dtd_info.set_elem_block('H3')
        self.a = self.dtd_info.set_elem_inline('A')
        # pre-built elem_obj's (only works for empty)
        self.br_el = spin_py.SPIN_elem_obj(self.br, [], [])
        self.hr_el = spin_py.SPIN_elem_obj(self.hr, [], [])

        self.lvl = {}
        self.lvl['H1'] = 1
        self.lvl['H2'] = 2
        self.lvl['H3'] = 3
        self.lvl_curr = 0
        self.list = {}
        self.list[0] = []  # holds entire result
        self.list[1] = []
        self.list[2] = []
        self.list[3] = []
        self.count = {}
        self.count[1] = 0
        self.count[2] = 0
        self.count[3] = 0
        self.div_toc = None
        self.kept_title = "NO-TITLE"

        self.request_callbacks_on_elem_infos()
Exemple #3
0
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
Exemple #4
0
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()
Exemple #5
0
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