~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/pack.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-23 17:00:36 UTC
  • mfrom: (4032.1.4 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090223170036-3q1v68ewdt8i0to5
(Marius Kruger) Remove all trailing whitespace and add tests to
        enforce this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
def _check_name(name):
36
36
    """Do some basic checking of 'name'.
37
 
    
 
37
 
38
38
    At the moment, this just checks that there are no whitespace characters in a
39
39
    name.
40
40
 
47
47
 
48
48
def _check_name_encoding(name):
49
49
    """Check that 'name' is valid UTF-8.
50
 
    
 
50
 
51
51
    This is separate from _check_name because UTF-8 decoding is relatively
52
52
    expensive, and we usually want to avoid it.
53
53
 
61
61
 
62
62
class ContainerSerialiser(object):
63
63
    """A helper class for serialising containers.
64
 
    
 
64
 
65
65
    It simply returns bytes from method calls to 'begin', 'end' and
66
66
    'bytes_record'.  You may find ContainerWriter to be a more convenient
67
67
    interface.
138
138
 
139
139
    def add_bytes_record(self, bytes, names):
140
140
        """Add a Bytes record with the given names.
141
 
        
 
141
 
142
142
        :param bytes: The bytes to insert.
143
143
        :param names: The names to give the inserted bytes. Each name is
144
144
            a tuple of bytestrings. The bytestrings may not contain
241
241
            names1, callable1 = record_iter.next()
242
242
            names2, callable2 = record_iter.next()
243
243
            bytes1 = callable1(None)
244
 
        
 
244
 
245
245
        As it will give incorrect results and invalidate the state of the
246
246
        ContainerReader.
247
247
 
252
252
        """
253
253
        self._read_format()
254
254
        return self._iter_records()
255
 
    
 
255
 
256
256
    def iter_record_objects(self):
257
257
        """Iterate over the container, yielding each record as it is read.
258
258
 
267
267
        """
268
268
        self._read_format()
269
269
        return self._iter_record_objects()
270
 
    
 
270
 
271
271
    def _iter_records(self):
272
272
        for record in self._iter_record_objects():
273
273
            yield record.read()
342
342
        except ValueError:
343
343
            raise errors.InvalidRecordError(
344
344
                "%r is not a valid length." % (length_line,))
345
 
        
 
345
 
346
346
        # Read the list of names.
347
347
        names = []
348
348
        while True:
415
415
        records = self._parsed_records
416
416
        self._parsed_records = []
417
417
        return records
418
 
    
 
418
 
419
419
    def _consume_line(self):
420
420
        """Take a line out of the buffer, and return the line.
421
421
 
468
468
            for name_part in name_parts:
469
469
                _check_name(name_part)
470
470
            self._current_record_names.append(name_parts)
471
 
            
 
471
 
472
472
    def _state_expecting_body(self):
473
473
        if len(self._buffer) >= self._current_record_length:
474
474
            body_bytes = self._buffer[:self._current_record_length]