/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 breezy/chk_serializer.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
from cStringIO import StringIO
22
 
 
23
 
from breezy import lazy_import
 
21
from . import lazy_import
24
22
lazy_import.lazy_import(globals(),
25
23
"""
26
24
from breezy import (
27
25
    xml_serializer,
28
26
    )
29
27
""")
30
 
from breezy import (
 
28
from . import (
31
29
    bencode,
32
30
    cache_utf8,
33
31
    errors,
34
32
    revision as _mod_revision,
35
33
    serializer,
36
34
    )
 
35
from .sixish import (
 
36
    BytesIO,
 
37
    )
 
38
 
37
39
 
38
40
 
39
41
def _validate_properties(props, _decode=cache_utf8._utf8_decode):
147
149
    format_num = '9'
148
150
    revision_format_num = None
149
151
    support_altered_by_hack = False
150
 
    supported_kinds = set(['file', 'directory', 'symlink', 'tree-reference'])
 
152
    supported_kinds = {'file', 'directory', 'symlink', 'tree-reference'}
151
153
 
152
154
    def __init__(self, node_size, search_key_name):
153
155
        self.maximum_size = node_size
181
183
                xml_serializer.fromstring(xml_string), revision_id,
182
184
                entry_cache=entry_cache,
183
185
                return_from_cache=return_from_cache)
184
 
        except xml_serializer.ParseError, e:
 
186
        except xml_serializer.ParseError as e:
185
187
            raise errors.UnexpectedInventoryFormat(e)
186
188
 
187
189
    def read_inventory(self, f, revision_id=None):
192
194
                    revision_id=None)
193
195
            finally:
194
196
                f.close()
195
 
        except xml_serializer.ParseError, e:
 
197
        except xml_serializer.ParseError as e:
196
198
            raise errors.UnexpectedInventoryFormat(e)
197
199
 
198
200
    def write_inventory_to_lines(self, inv):
200
202
        return self.write_inventory(inv, None)
201
203
 
202
204
    def write_inventory_to_string(self, inv, working=False):
203
 
        """Just call write_inventory with a StringIO and return the value.
 
205
        """Just call write_inventory with a BytesIO and return the value.
204
206
 
205
207
        :param working: If True skip history data - text_sha1, text_size,
206
208
            reference_revision, symlink_target.
207
209
        """
208
 
        sio = StringIO()
 
210
        sio = BytesIO()
209
211
        self.write_inventory(inv, sio, working)
210
212
        return sio.getvalue()
211
213