File: drv_htmllib.py

package info (click to toggle)
qm 1.1.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,628 kB
  • ctags: 10,249
  • sloc: python: 41,482; ansic: 20,611; xml: 12,837; sh: 485; makefile: 226
file content (50 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
SAX driver for htmllib.py

$Id: drv_htmllib.py,v 1.1.1.1 2001/07/17 04:47:38 samuel Exp $
"""

version="0.10"

from xml.sax import saxutils,saxlib
from xml.sax.drivers import pylibs

import htmllib,sys,string

# --- SAX_HLParser

class SAX_HLParser(pylibs.SGMLParsers,htmllib.HTMLParser):
    "SAX driver for htmllib.py."

    def __init__(self):
	htmllib.HTMLParser.__init__(self,None)
        pylibs.LibParser.__init__(self)
        self.standalone=0

    # --- EXPERIMENTAL PYTHON SAX EXTENSIONS
        
    def get_parser_name(self):
        return "htmllib"

    def get_parser_version(self):
        return sys.version[:string.find(sys.version," ")]

    def get_driver_version(self):
        return version
    
    def is_validating(self):
        return 0

    def is_dtd_reading(self):
        return 0

    # reset and feed are taken care of by the subclassing :-)
    
    def close(self):
        htmllib.HTMLParser.close(self)
	self.doc_handler.endDocument()
    
# --- Global functions

def create_parser():
    return SAX_HLParser()