/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/iterablefile.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 01:35:53 UTC
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610013553-560y7mn3su4pp763
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
 
18
from __future__ import absolute_import
18
19
 
19
20
class IterableFileBase(object):
20
21
    """Create a file-like object from any iterable"""
66
67
        result = self._buffer
67
68
        while result_length(result) is None:
68
69
            try:
69
 
                result += self._iter.next()
 
70
                result += next(self._iter)
70
71
            except StopIteration:
71
72
                self.done = True
72
73
                self._buffer = ""
141
142
        """
142
143
        self._check_closed()
143
144
 
144
 
    def next(self):
 
145
    def __next__(self):
145
146
        """Implementation of the iterator protocol's next()
146
147
 
147
148
        >>> f = IterableFile(['This \\n', 'is ', 'a ', 'test.'])
148
 
        >>> f.next()
 
149
        >>> next(f)
149
150
        'This \\n'
150
151
        >>> f.close()
151
 
        >>> f.next()
 
152
        >>> next(f)
152
153
        Traceback (most recent call last):
153
154
        ValueError: File is closed.
154
155
        >>> f = IterableFile(['This \\n', 'is ', 'a ', 'test.\\n'])
155
 
        >>> f.next()
 
156
        >>> next(f)
156
157
        'This \\n'
157
 
        >>> f.next()
 
158
        >>> next(f)
158
159
        'is a test.\\n'
159
 
        >>> f.next()
 
160
        >>> next(f)
160
161
        Traceback (most recent call last):
161
162
        StopIteration
162
163
        """
163
164
        self._check_closed()
164
 
        return self._iter.next()
 
165
        return next(self._iter)
 
166
 
 
167
    next = __next__
165
168
 
166
169
    def __iter__(self):
167
170
        """