/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: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
# importing this module is fairly slow because it has to load several
23
23
# ElementTree bits
24
24
 
 
25
from bzrlib import registry
25
26
from bzrlib.trace import mutter, warning
26
27
 
27
28
try:
50
51
 
51
52
class Serializer(object):
52
53
    """Abstract object serialize/deserialize"""
 
54
 
53
55
    def write_inventory(self, inv, f):
54
56
        """Write inventory to a file"""
55
 
        elt = self._pack_inventory(inv)
56
 
        self._write_element(elt, f)
 
57
        raise NotImplementedError(self.write_inventory)
57
58
 
58
59
    def write_inventory_to_string(self, inv):
59
 
        return tostring(self._pack_inventory(inv)) + '\n'
 
60
        raise NotImplementedError(self.write_inventory_to_string)
60
61
 
61
62
    def read_inventory_from_string(self, xml_string):
62
63
        try:
155
156
        elementtree.ElementTree._raise_serialization_error(text)
156
157
 
157
158
elementtree.ElementTree._escape_cdata = _escape_cdata
 
159
 
 
160
 
 
161
class SerializerRegistry(registry.Registry):
 
162
    """Registry for serializer objects"""
 
163
 
 
164
 
 
165
format_registry = SerializerRegistry()
 
166
format_registry.register_lazy('4', 'bzrlib.xml4', 'serializer_v4')
 
167
format_registry.register_lazy('5', 'bzrlib.xml5', 'serializer_v5')
 
168
format_registry.register_lazy('6', 'bzrlib.xml6', 'serializer_v6')
 
169
format_registry.register_lazy('7', 'bzrlib.xml7', 'serializer_v7')