~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml.py

  • Committer: Robert Collins
  • Date: 2005-10-03 05:54:35 UTC
  • mto: (1393.1.30)
  • mto: This revision was merged to the branch mainline in revision 1400.
  • Revision ID: robertc@robertcollins.net-20051003055434-c8ebd30d1de10247
move exporting functionality into inventory.py - uncovers bug in symlink support

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
1
2
# -*- coding: UTF-8 -*-
2
3
 
3
4
# This program is free software; you can redistribute it and/or modify
28
29
    from cElementTree import (ElementTree, SubElement, Element,
29
30
                              XMLTreeBuilder, fromstring, tostring)
30
31
except ImportError:
31
 
    mutter('WARNING: using slower ElementTree; consider installing cElementTree'
32
 
           " and make sure it's on your PYTHONPATH")
 
32
    ## from warnings import warn
 
33
    ## warn('using slower ElementTree; consider installing cElementTree')
33
34
    from util.elementtree.ElementTree import (ElementTree, SubElement,
34
35
                                              Element, XMLTreeBuilder,
35
36
                                              fromstring, tostring)
36
37
 
 
38
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
37
39
from bzrlib.errors import BzrError
38
40
 
39
41
 
45
47
        self._write_element(elt, f)
46
48
 
47
49
    def write_inventory_to_string(self, inv):
48
 
        return tostring(self._pack_inventory(inv)) + '\n'
 
50
        return tostring(self._pack_inventory(inv))
49
51
 
50
52
    def read_inventory_from_string(self, xml_string):
51
53
        return self._unpack_inventory(fromstring(xml_string))
57
59
        self._write_element(self._pack_revision(rev), f)
58
60
 
59
61
    def write_revision_to_string(self, rev):
60
 
        return tostring(self._pack_revision(rev)) + '\n'
 
62
        return tostring(self._pack_revision(rev), f)
61
63
 
62
64
    def read_revision(self, f):
63
65
        return self._unpack_revision(self._read_element(f))