~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

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)
45
46
        self._write_element(elt, f)
46
47
 
47
48
    def write_inventory_to_string(self, inv):
48
 
        return tostring(self._pack_inventory(inv)) + '\n'
 
49
        return tostring(self._pack_inventory(inv))
49
50
 
50
51
    def read_inventory_from_string(self, xml_string):
51
52
        return self._unpack_inventory(fromstring(xml_string))
57
58
        self._write_element(self._pack_revision(rev), f)
58
59
 
59
60
    def write_revision_to_string(self, rev):
60
 
        return tostring(self._pack_revision(rev)) + '\n'
 
61
        return tostring(self._pack_revision(rev), f)
61
62
 
62
63
    def read_revision(self, f):
63
64
        return self._unpack_revision(self._read_element(f))