Try to deal with _xmlplus module if present instead of xml

svn: r173
This commit is contained in:
Don Allingham 2001-06-21 23:14:01 +00:00
parent be86a6dcaa
commit 3daa17e100
5 changed files with 51 additions and 37 deletions

View File

@ -36,9 +36,16 @@ try:
f.write("YES")
f.close()
except ImportError:
f = open("conftest.out", "w")
f.write("NO")
f.close()
try:
from _xmlplus.sax import saxlib
f = open("conftest.out", "w")
f.write("YES")
f.close()
except ImportError:
f = open("conftest.out", "w")
f.write("NO")
f.close()
EOF
changequote([, ])
$PYTHON conftest.py

View File

@ -23,24 +23,8 @@ from TextDoc import *
import string
import os
import sys
import xml.sax
import xml.sax.saxutils
import utils
#-------------------------------------------------------------------------
#
# Try to abstract SAX1 from SAX2
#
#-------------------------------------------------------------------------
if sys.version[0] != '1':
sax = 2
else:
try:
import xml.sax.saxexts
sax = 1
except:
sax = 2
#------------------------------------------------------------------------
#
#

View File

@ -25,8 +25,6 @@ import string
import os
import sys
from xml.sax import handler
#-------------------------------------------------------------------------
#
# Try to abstract SAX1 from SAX2
@ -34,8 +32,13 @@ from xml.sax import handler
#-------------------------------------------------------------------------
if sys.version[0] != '1':
sax = 2
try:
from _xmlplus.sax import handler
else:
from xml.sax import handler
else:
try:
from xml.sax import handler
import xml.sax.saxexts
sax = 1
except:

View File

@ -31,8 +31,13 @@ import os
from gnome.ui import *
import sys
import xml.sax
import xml.sax.saxutils
try:
import _xmlplus.sax
import _xmlplus.sax.saxutils
except:
import xml.sax
import xml.sax.saxutils
#-------------------------------------------------------------------------
#
@ -42,11 +47,18 @@ import xml.sax.saxutils
if sys.version[0] != '1':
sax = 2
try:
from _xmlplus.sax import make_parser, SAXParseException
except:
from xml.sax import make_parser, SAXParseException
else:
try:
import xml.sax.saxexts
from xml.sax.saxexts import make_parser
from xml.sax import SAXParseException
from xml.sax.saxutils import ErrorRaiser
sax = 1
except:
from xml.sax import make_parser, SAXParseException
sax = 2
#-------------------------------------------------------------------------
@ -63,12 +75,12 @@ def importData(database, filename, callback):
database.fmap = {}
if sax == 1:
parser = xml.sax.saxexts.make_parser()
parser = make_parser()
parser.setDocumentHandler(GrampsImportParser(database,callback,basefile))
parser.setErrorHandler(xml.sax.saxutils.ErrorRaiser())
parser.setErrorHandler(ErrorRaiser())
else:
parser = xml.sax.make_parser()
parser = make_parser()
parser.setContentHandler(GrampsImportParser(database,callback,basefile))
try:
@ -119,11 +131,11 @@ def loadData(database, filename, callback):
filename = os.path.normpath(filename)
if sax == 1:
parser = xml.sax.saxexts.make_parser()
parser = make_parser()
parser.setDocumentHandler(GrampsParser(database,callback,basefile))
parser.setErrorHandler(xml.sax.saxutils.ErrorRaiser())
parser.setErrorHandler(ErrorRaiser())
else:
parser = xml.sax.make_parser()
parser = make_parser()
parser.setContentHandler(GrampsParser(database,callback,basefile))
try:

View File

@ -21,8 +21,6 @@
import string
import os
import sys
import xml.sax
import xml.sax.saxutils
import utils
#-------------------------------------------------------------------------
@ -32,11 +30,21 @@ import utils
#-------------------------------------------------------------------------
if sys.version[0] != '1':
sax = 2
try:
from _xmlplus.sax import make_parser
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
@ -466,12 +474,12 @@ class StyleSheetList:
return
if sax == 1:
parser = xml.sax.saxexts.make_parser()
parser = make_parser()
parser.setDocumentHandler(SheetParser(self))
parser.setErrorHandler(xml.sax.saxutils.ErrorRaiser())
parser.setErrorHandler(ErrorRaiser())
parser.parseFile(f)
else:
parser = xml.sax.make_parser()
parser = make_parser()
parser.setContentHandler(SheetParser(self))
parser.parse(f)
@ -510,9 +518,9 @@ class StyleSheet:
#
#
#-------------------------------------------------------------------------
class SheetParser(xml.sax.handler.ContentHandler):
class SheetParser(handler.ContentHandler):
def __init__(self,sheetlist):
xml.sax.handler.ContentHandler.__init__(self)
handler.ContentHandler.__init__(self)
self.sheetlist = sheetlist
self.f = None
self.p = None