~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml4.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-02 00:43:10 UTC
  • mfrom: (2057.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20061002004310-6e09ddd7fd28f71c
Merge in 0.11 NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
 
3
1
# This program is free software; you can redistribute it and/or modify
4
2
# it under the terms of the GNU General Public License as published by
5
3
# the Free Software Foundation; either version 2 of the License, or
6
4
# (at your option) any later version.
7
 
 
 
5
#
8
6
# This program is distributed in the hope that it will be useful,
9
7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
9
# GNU General Public License for more details.
12
 
 
 
10
#
13
11
# You should have received a copy of the GNU General Public License
14
12
# along with this program; if not, write to the Free Software
15
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
14
 
17
15
 
18
 
from bzrlib.xml import ElementTree, SubElement, Element, Serializer
 
16
from bzrlib.xml_serializer import ElementTree, SubElement, Element, Serializer
19
17
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
20
18
import bzrlib.inventory as inventory
21
19
from bzrlib.revision import Revision        
29
27
class _Serializer_v4(Serializer):
30
28
    """Version 0.0.4 serializer
31
29
 
32
 
    You should use the serialzer_v4 singleton."""
 
30
    You should use the serializer_v4 singleton."""
33
31
    
34
32
    __slots__ = []
35
33
    
36
34
    def _pack_inventory(self, inv):
37
35
        """Convert to XML Element"""
 
36
        # v4 serialization is not used any more.
 
37
        raise NotImplementedError(self._pack_inventory)
38
38
        e = Element('inventory')
39
39
        e.text = '\n'
40
40
        if inv.root.file_id not in (None, ROOT_ID):
51
51
        e.set('file_id', ie.file_id)
52
52
        e.set('kind', ie.kind)
53
53
 
54
 
        if ie.text_size != None:
 
54
        if ie.text_size is not None:
55
55
            e.set('text_size', '%d' % ie.text_size)
56
56
 
57
57
        for f in ['text_id', 'text_sha1', 'symlink_target']:
58
58
            v = getattr(ie, f)
59
 
            if v != None:
 
59
            if v is not None:
60
60
                e.set(f, v)
61
61
 
62
62
        # to be conservative, we don't externalize the root pointers
92
92
        ## nodes in the root directory, but it's cleaner to use one
93
93
        ## internally.
94
94
        parent_id = elt.get('parent_id')
95
 
        if parent_id == None:
 
95
        if parent_id is None:
96
96
            parent_id = ROOT_ID
97
97
 
98
98
        kind = elt.get('kind')
116
116
        else:
117
117
            raise BzrError("unknown kind %r" % kind)
118
118
 
119
 
        ## mutter("read inventoryentry: %r" % (elt.attrib))
 
119
        ## mutter("read inventoryentry: %r", elt.attrib)
120
120
 
121
121
        return ie
122
122