29
from bzrlib.serializer import Serializer
30
from bzrlib.trace import mutter
30
import xml.etree.cElementTree as elementtree
31
ParseError = getattr(elementtree, "ParseError", SyntaxError)
33
# Fall back to pure python implementation if C extention is unavailable
34
import xml.etree.ElementTree as elementtree
34
# it's in this package in python2.5
35
from xml.etree.cElementTree import (ElementTree, SubElement, Element,
36
XMLTreeBuilder, fromstring, tostring)
37
import xml.etree as elementtree
38
# Also import ElementTree module so monkey-patching below always works
39
import xml.etree.ElementTree
36
from xml.etree.ElementTree import ParseError
40
37
except ImportError:
41
from cElementTree import (ElementTree, SubElement, Element,
42
XMLTreeBuilder, fromstring, tostring)
43
import elementtree.ElementTree
44
ParseError = SyntaxError
46
mutter('WARNING: using slower ElementTree; consider installing cElementTree'
47
" and make sure it's on your PYTHONPATH")
48
# this copy is shipped with bzr
49
from util.elementtree.ElementTree import (ElementTree, SubElement,
50
Element, XMLTreeBuilder,
52
import util.elementtree as elementtree
53
from xml.parsers.expat import ExpatError as ParseError
38
from xml.parsers.expat import ExpatError as ParseError
40
(ElementTree, SubElement, Element, XMLTreeBuilder, fromstring, tostring) = (
41
elementtree.ElementTree, elementtree.SubElement, elementtree.Element,
42
elementtree.XMLTreeBuilder, elementtree.fromstring, elementtree.tostring)
55
45
from bzrlib import (
63
class XMLSerializer(Serializer):
54
class XMLSerializer(serializer.Serializer):
64
55
"""Abstract XML object serialize/deserialize"""
66
57
squashes_xml_invalid_characters = True