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)
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
41
from cElementTree import (ElementTree, SubElement, Element,
42
XMLTreeBuilder, fromstring, tostring)
43
import elementtree.ElementTree
44
ParseError = SyntaxError
32
45
except ImportError:
33
# Fall back to pure python implementation if C extension is unavailable
34
import xml.etree.ElementTree as elementtree
36
from xml.etree.ElementTree import 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)
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
45
55
from bzrlib import (
54
class XMLSerializer(serializer.Serializer):
63
class XMLSerializer(Serializer):
55
64
"""Abstract XML object serialize/deserialize"""
57
66
squashes_xml_invalid_characters = True
311
320
ie.symlink_target = elt_get('symlink_target')
312
elif kind == 'tree-reference':
313
file_id = elt.attrib['file_id']
314
name = elt.attrib['name']
315
parent_id = elt.attrib['parent_id']
316
revision = elt.get('revision')
317
reference_revision = elt.get('reference_revision')
318
ie = inventory.TreeReference(file_id, name, parent_id, revision,
321
322
raise errors.UnsupportedInventoryKind(kind)
322
323
ie.revision = revision