~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/pack.py

  • Committer: Robert Collins
  • Date: 2007-08-15 01:12:57 UTC
  • mto: This revision was merged to the branch mainline in revision 2740.
  • Revision ID: robertc@robertcollins.net-20070815011257-kxmspgdwk2l36h0x
Add records_written attribute to ContainerWriter's. (Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
 
61
61
class ContainerWriter(object):
62
 
    """A class for writing containers."""
 
62
    """A class for writing containers.
 
63
 
 
64
    :attribute records_written: The number of user records added to the
 
65
        container. This does not count the prelude or suffix of the container
 
66
        introduced by the begin() and end() methods.
 
67
    """
63
68
 
64
69
    def __init__(self, write_func):
65
70
        """Constructor.
69
74
        """
70
75
        self._write_func = write_func
71
76
        self.current_offset = 0
 
77
        self.records_written = 0
72
78
 
73
79
    def begin(self):
74
80
        """Begin writing a container."""
112
118
        self.write_func("\n")
113
119
        # Finally, the contents.
114
120
        self.write_func(bytes)
 
121
        self.records_written += 1
115
122
        # return a memo of where we wrote data to allow random access.
116
123
        return current_offset, self.current_offset - current_offset
117
124