/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/xml_serializer.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-13 02:09:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2004.
  • Revision ID: john@arbash-meinel.com-20060913020937-2df2f49f9a28ec43
Update HACKING and docstrings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# -*- coding: UTF-8 -*-
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
25
25
from bzrlib.trace import mutter, warning
26
26
 
27
27
try:
28
 
    try:
29
 
        # it's in this package in python2.5
30
 
        from xml.etree.cElementTree import (ElementTree, SubElement, Element,
31
 
            XMLTreeBuilder, fromstring, tostring)
32
 
        import xml.etree as elementtree
33
 
    except ImportError:
34
 
        from cElementTree import (ElementTree, SubElement, Element,
35
 
                                  XMLTreeBuilder, fromstring, tostring)
36
 
        import elementtree
37
 
    ParseError = SyntaxError
 
28
    from cElementTree import (ElementTree, SubElement, Element,
 
29
                              XMLTreeBuilder, fromstring, tostring)
 
30
    import elementtree
38
31
except ImportError:
39
32
    mutter('WARNING: using slower ElementTree; consider installing cElementTree'
40
33
           " and make sure it's on your PYTHONPATH")
41
 
    # this copy is shipped with bzr
42
34
    from util.elementtree.ElementTree import (ElementTree, SubElement,
43
35
                                              Element, XMLTreeBuilder,
44
36
                                              fromstring, tostring)
45
37
    import util.elementtree as elementtree
46
 
    from xml.parsers.expat import ExpatError as ParseError
47
38
 
48
39
from bzrlib import errors
49
40
 
61
52
    def read_inventory_from_string(self, xml_string):
62
53
        try:
63
54
            return self._unpack_inventory(fromstring(xml_string))
64
 
        except ParseError, e:
 
55
        except SyntaxError, e:
65
56
            raise errors.UnexpectedInventoryFormat(e)
66
57
 
67
58
    def read_inventory(self, f):
68
59
        try:
69
60
            return self._unpack_inventory(self._read_element(f))
70
 
        except ParseError, e:
 
61
        except SyntaxError, e:
71
62
            raise errors.UnexpectedInventoryFormat(e)
72
63
 
73
64
    def write_revision(self, rev, f):