27
from bzrlib.serializer import Serializer
28
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
32
# it's in this package in python2.5
33
from xml.etree.cElementTree import (ElementTree, SubElement, Element,
34
XMLTreeBuilder, fromstring, tostring)
35
import xml.etree as elementtree
36
# Also import ElementTree module so monkey-patching below always works
37
import xml.etree.ElementTree
36
from xml.etree.ElementTree import ParseError
38
37
except ImportError:
39
from cElementTree import (ElementTree, SubElement, Element,
40
XMLTreeBuilder, fromstring, tostring)
41
import elementtree.ElementTree
42
ParseError = SyntaxError
44
mutter('WARNING: using slower ElementTree; consider installing cElementTree'
45
" and make sure it's on your PYTHONPATH")
46
# this copy is shipped with bzr
47
from util.elementtree.ElementTree import (ElementTree, SubElement,
48
Element, XMLTreeBuilder,
50
import util.elementtree as elementtree
51
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)
53
45
from bzrlib import (
61
class XMLSerializer(Serializer):
54
class XMLSerializer(serializer.Serializer):
62
55
"""Abstract XML object serialize/deserialize"""
64
57
squashes_xml_invalid_characters = True