/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: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from __future__ import absolute_import
19
19
 
 
20
 
20
21
class IterableFileBase(object):
21
22
    """Create a file-like object from any iterable"""
22
23
 
51
52
                if len(result) >= length:
52
53
                    return length
53
54
            try:
54
 
                return result.index(sequence)+len(sequence)
 
55
                return result.index(sequence) + len(sequence)
55
56
            except ValueError:
56
57
                return None
57
58
        return self._read(test_contents)
85
86
            return None
86
87
        return self._read(no_stop)
87
88
 
88
 
 
89
89
    def push_back(self, contents):
90
90
        """
91
91
        >>> f = IterableFileBase(['Th\\nis ', 'is \\n', 'a ', 'te\\nst.'])
140
140
        # If there was an error raised, prefer the original one
141
141
        try:
142
142
            self.close()
143
 
        except:
 
143
        except BaseException:
144
144
            if exc_type is None:
145
145
                raise
146
146
        return False