Maybe solved the PyXML/python1/2 problem?

svn: r192
This commit is contained in:
Don Allingham 2001-06-28 15:23:16 +00:00
parent 262b839057
commit 257be330e8
2 changed files with 16 additions and 48 deletions

View File

@ -31,18 +31,15 @@ import sys
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if sys.version[0] != '1': if sys.version[0] != '1':
sax = 2
try: try:
from _xmlplus.sax import handler from _xmlplus.sax import handler
from _xmlplus.sax import make_parser
except: except:
from xml.sax import handler from xml.sax import handler
from xml.sax import make_parser
else: else:
try: from xml.sax import handler
from xml.sax import handler from xml.sax import make_parser
import xml.sax.saxexts
sax = 1
except:
sax = 2
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -858,14 +855,9 @@ class GrampsParser(handler.ContentHandler):
self.func_index = self.func_index - 1 self.func_index = self.func_index - 1
self.func,self.data = self.func_list[self.func_index] self.func,self.data = self.func_list[self.func_index]
if sax == 1: def characters(self, data):
def characters(self, data, offset, length): if self.func:
if self.func: self.data = self.data + data
self.data = self.data + data
else:
def characters(self, data):
if self.func:
self.data = self.data + data

View File

@ -28,24 +28,10 @@ import utils
# Try to abstract SAX1 from SAX2 # Try to abstract SAX1 from SAX2
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if sys.version[0] != '1': try:
sax = 2 from xml.sax import make_parser,handler
try: except:
from _xmlplus.sax import make_parser from _xmlplus.sax import make_parser,handler
from _xmlplus.sax import handler
except:
from xml.sax import make_parser
from xml.sax import handler
else:
try:
import xml.sax.saxexts
from xml.sax.saxutils import ErrorRaiser
from xml.sax import handler
sax = 1
except:
from xml.sax.saxutils import ErrorRaiser
from xml.sax import handler
sax = 2
FONT_SANS_SERIF = 0 FONT_SANS_SERIF = 0
FONT_SERIF = 1 FONT_SERIF = 1
@ -473,15 +459,9 @@ class StyleSheetList:
except: except:
return return
if sax == 1: parser = make_parser()
parser = make_parser() parser.setContentHandler(SheetParser(self))
parser.setDocumentHandler(SheetParser(self)) parser.parse(f)
parser.setErrorHandler(ErrorRaiser())
parser.parseFile(f)
else:
parser = make_parser()
parser.setContentHandler(SheetParser(self))
parser.parse(f)
f.close() f.close()
@ -566,12 +546,8 @@ class SheetParser(handler.ContentHandler):
elif tag == "sheet": elif tag == "sheet":
self.sheetlist.set_style_sheet(self.sname,self.s) self.sheetlist.set_style_sheet(self.sname,self.s)
if sax == 1: def characters(self, data):
def characters(self, data, offset, length): pass
pass
else:
def characters(self, data):
pass
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #