diff --git a/gramps/configure.in b/gramps/configure.in index 5e9e12f80..3e394a3c8 100644 --- a/gramps/configure.in +++ b/gramps/configure.in @@ -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 diff --git a/gramps/src/DrawDoc.py b/gramps/src/DrawDoc.py index e11fabffe..c2c0d635c 100644 --- a/gramps/src/DrawDoc.py +++ b/gramps/src/DrawDoc.py @@ -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 - #------------------------------------------------------------------------ # # diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py index cc2595b57..728a9665c 100644 --- a/gramps/src/GrampsParser.py +++ b/gramps/src/GrampsParser.py @@ -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: diff --git a/gramps/src/ReadXML.py b/gramps/src/ReadXML.py index af99cc7dc..be7cf76db 100644 --- a/gramps/src/ReadXML.py +++ b/gramps/src/ReadXML.py @@ -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: diff --git a/gramps/src/TextDoc.py b/gramps/src/TextDoc.py index 0a555dd36..a753bc3cf 100644 --- a/gramps/src/TextDoc.py +++ b/gramps/src/TextDoc.py @@ -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